26 #include <Classes.hpp>
27 #include <Controls.hpp>
28 #include <StdCtrls.hpp>
30 #include <Buttons.hpp>
31 #include <ExtCtrls.hpp>
33 #include <Dialogs.hpp>
34 #include <Graphics.hpp>
35 #include <ComCtrls.hpp>
50 #pragma package(smart_init)
63 Graphics::TBitmap* SmallGraphicPtrVal) : SpeedTag(SpeedTagVal), TrackType(TrackTypeVal), GraphicPtr(GraphicPtrVal), SmallGraphicPtr(SmallGraphicPtrVal)
65 for(
int x = 0; x < 4; x++)
76 else if(SpeedTagVal == 77)
80 else if(SpeedTagVal == 78)
84 else if(SpeedTagVal == 79)
88 else if(SpeedTagVal == 96)
92 else if(SpeedTagVal == 129)
96 else if(SpeedTagVal == 130)
100 else if(SpeedTagVal == 131)
104 else if(SpeedTagVal == 145)
108 else if(SpeedTagVal == 146)
117 FixedNamedLocationElement(false)
119 for(
int x = 0; x < 4; x++)
130 AnsiString(VLocInput));
143 if((this->
HLoc == RHElement.
HLoc) && (this->VLoc == RHElement.
VLoc) && (this->SpeedTag == RHElement.
SpeedTag))
157 if((this->
HLoc != RHElement.
HLoc) || (this->VLoc != RHElement.
VLoc) || (this->SpeedTag != RHElement.
SpeedTag))
173 Graphics::TBitmap *GraphicOutput = GraphicPtr;
175 if(LocationName ==
"")
220 GraphicOutput = GraphicPtr;
224 Disp->PlotOutput(34, HLoc * 16, VLoc * 16, GraphicOutput);
233 AnsiString LogString =
"TrkEl:-," + AnsiString(ElementID) +
"," + LocationName +
"," + AnsiString(TrainIDOnElement) +
"," +
234 AnsiString(TrainIDOnBridgeTrackPos01) +
"," + AnsiString(TrainIDOnBridgeTrackPos23) +
",EndTrkEl,";
243 if(lower.second < higher.second)
247 else if(lower.second > higher.second)
251 else if(lower.second == higher.second)
253 if(lower.first < higher.first)
266 :
TTrackElement(ElementIn), ELink(ELinkIn), ELinkPos(ELinkPosIn), XLink(XLinkIn), XLinkPos(XLinkPosIn), TrackVectorPosition(TrackVectorPositionIn),
267 CheckCount(9), IsARoute(false), AutoSignals(false), PrefDirRoute(false)
271 throw Exception(
"EXNumber failure in TPrefDirElement constructor");
282 AnsiString LogString =
"PthEl:-," + AnsiString(
ELink) +
"," + AnsiString(
ELinkPos) +
"," + AnsiString(
XLink) +
"," + AnsiString(
XLinkPos) +
"," +
310 {2, 4}, {6, 2}, {8, 6}, {4, 8},
311 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
321 else if(
Link[2] == -1)
334 else if(
Link[2] == -1)
343 for(
int x = 0; x < 16; x++)
345 if(((Entry == EXArray[x][0]) && (Exit == EXArray[x][1])) || ((Entry == EXArray[x][1]) && (Exit == EXArray[x][0])))
521 throw Exception(
"Error in EntryExitNumber 4");
616 throw Exception(
"Error in EntryExitNumber 5");
713 throw Exception(
"Error in EntryExitNumber 6");
803 throw Exception(
"Error in EntryExitNumber 10");
893 throw Exception(
"Error in EntryExitNumber 11");
989 throw Exception(
"Error in EntryExitNumber 7");
1020 throw Exception(
"Error in EntryExitNumber 8");
1031 if((ELink > 0) && (ELink < 10) && (ELink != 5))
1033 if(!AutoSigsFlag && !PrefDirRoute)
1037 else if(!AutoSigsFlag && PrefDirRoute)
1048 throw Exception(
"Error in EntryExitNumber 9");
1092 TTrack::TActiveLevelCrossing::TActiveLevelCrossing()
1116 AnsiString NL =
'\n';
1118 RouteFailMessage =
"Unable to set a route:" + NL + NL +
"it may be unreachable; " + NL + NL +
1119 "reachable but with too many different directions leading away from the start point - set some points on the route required; " + NL + NL +
1120 "blocked by a train, another route or a changing level crossing; " + NL + NL +
1121 "or invalid - possibly due to a preferred direction mismatch, or a missed signal in a blue route or green route restricted to consecutive signals.";
1128 int InternalLinkCheckArray[9][2] =
1129 {{1, 9}, {4, 6}, {7, 3}, {2, 8}, {0, 0}, {8, 2}, {3, 7}, {6, 4}, {9, 1}};
1134 for(
int x = 0; x < 9; x++)
1136 for(
int y = 0; y < 2; y++)
1143 TopPlatAllowed << 1 << 9 << 10 << 30 << 31 << 60 << 61 << 68 << 69 << 77 << 125 << 126 << 129 << 145;
1145 BotPlatAllowed << 1 << 7 << 8 << 28 << 29 << 60 << 61 << 68 << 69 << 76 << 125 << 126 << 129 << 145;
1146 LeftPlatAllowed << 2 << 12 << 14 << 33 << 35 << 62 << 63 << 70 << 71 << 79 << 127 << 128 << 130 << 146;
1147 RightPlatAllowed << 2 << 11 << 13 << 32 << 34 << 62 << 63 << 70 << 71 << 78 << 127 << 128 << 130 << 146;
1148 NameAllowed << 1 << 2 << 3 << 4 << 5 << 6 << 20 << 21 << 22 << 23 << 24 << 25 << 26 << 27
1149 << 60 << 61 << 62 << 63 << 68 << 69 << 70 << 71 << 80 << 81 << 82 << 83 << 125 << 126 << 127 << 128;
1155 int HVArray[10][2] =
1156 {{0, 0}, {-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {0, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};
1158 for(
int x = 0; x < 10; x++)
1160 for(
int y = 0; y < 2; y++)
1169 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1172 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1173 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1175 {68, 2,
RailGraphics->
bm68dblyellow}, {69, 2,
RailGraphics->
bm69dblyellow}, {70, 2,
RailGraphics->
bm70dblyellow}, {71, 2,
RailGraphics->
bm71dblyellow},
1176 {72, 2,
RailGraphics->
bm72dblyellow}, {73, 2,
RailGraphics->
bm73dblyellow}, {74, 2,
RailGraphics->
bm74dblyellow}, {75, 2,
RailGraphics->
bm75dblyellow},
1178 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1179 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1182 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1185 for(
int x = 0; x < 40; x++)
1191 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1194 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1195 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1197 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1198 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1200 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1201 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1204 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1207 for(
int x = 0; x < 40; x++)
1213 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1216 {68, 1,
RailGraphics->
bm68green}, {69, 1,
RailGraphics->
bm69green}, {70, 1,
RailGraphics->
bm70green}, {71, 1,
RailGraphics->
bm71green},
1217 {72, 1,
RailGraphics->
bm72green}, {73, 1,
RailGraphics->
bm73green}, {74, 1,
RailGraphics->
bm74green}, {75, 1,
RailGraphics->
bm75green},
1219 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1220 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1222 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1223 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1226 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1229 for(
int x = 0; x < 40; x++)
1255 for(
int x = 0; x < 40; x++)
1282 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1283 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1284 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {0, 0, 77}, {-1, 0, 78},
1285 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1286 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, -1, 129},
1287 {0, 0, 129}, {0, -1, 145},
1290 for(
int x = 0; x < 25; x++)
1292 for(
int y = 0; y < 3; y++)
1300 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1301 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {0, 0, 76}, {-1, 0, 77},
1302 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1303 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1304 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1305 {0, 0, 129}, {0, 1, 145},
1308 for(
int x = 0; x < 25; x++)
1310 for(
int y = 0; y < 3; y++)
1318 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1319 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1320 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1321 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1322 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 0, 79}, {-1, 0, 130},
1323 {0, 0, 130}, {-1, 0, 146},
1326 for(
int x = 0; x < 25; x++)
1328 for(
int y = 0; y < 3; y++)
1336 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1337 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1338 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1339 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {0, 0, 78}, {-1, 0, 79},
1340 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {1, 0, 130},
1341 {0, 0, 130}, {1, 0, 146},
1344 for(
int x = 0; x < 25; x++)
1346 for(
int y = 0; y < 3; y++)
1354 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1355 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1356 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1357 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1358 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1359 {0, -1, 129}, {1, 0, 130},
1360 {-1, 0, 130}, {0, 1, 145},
1361 {0, -1, 145}, {1, 0, 146},
1364 for(
int x = 0; x < 28; x++)
1366 for(
int y = 0; y < 3; y++)
1384 for(
int x = 0; x < 8; x++)
1386 for(
int y = 0; y < 3; y++)
1404 for(
int x = 0; x < 8; x++)
1406 for(
int y = 0; y < 3; y++)
1424 for(
int x = 0; x < 8; x++)
1426 for(
int y = 0; y < 3; y++)
1444 for(
int x = 0; x < 8; x++)
1446 for(
int y = 0; y < 3; y++)
1454 {1, 0, 131}, {0, -1, 131}, {0, 1, 131}};
1456 for(
int x = 0; x < 4; x++)
1458 for(
int y = 0; y < 3; y++)
1466 0, 1, 2, 5, 6, 3, 4, 9, 10, 7, 8, 13, 14, 11, 12, 15, 16, 17, 19, 18, 22, 23, 20, 21, 26, 27, 24, 25, 30, 31, 28, 29, 34, 35, 32, 33, 38, 39, 36, 37, 42,
1467 43, 40, 41, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 60, 61, 63, 62, 66, 67, 64, 65, 68, 69, 71, 70, 74, 75, 72, 73, 77, 76, 78,
1468 79, 80, 81, 83, 82, 86, 87, 84, 85, 88, 89, 91, 90, 94, 95, 92, 93, 96, 99, 100, 97, 98, 103, 104, 101, 102, 106, 105, 109, 110, 107, 108, 113, 114,
1469 111, 112, 117, 118, 115, 116, 119, 120, 121, 123, 122, 124, 125, 126, 128, 127, 129, 130, 131, 134, 133, 132, 135, 139, 138, 137, 136, 143, 142, 141,
1475 0, 1, 2, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15, 16, 17, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41,
1476 40, 43, 42, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 62, 63, 65, 64, 67, 66, 69, 68, 70, 71, 73, 72, 75, 74, 76, 77, 79,
1477 78, 81, 80, 82, 83, 85, 84, 87, 86, 89, 88, 90, 91, 93, 92, 95, 94, 96, 98, 97, 100, 99, 102, 101, 104, 103, 106, 105, 108, 107, 110, 109, 112, 111,
1478 114, 113, 116, 115, 118, 117, 119, 120, 124, 122, 123, 121, 126, 125, 127, 128, 129, 130, 131, 132, 135, 134, 133, 137, 136, 139, 138, 142, 143, 140,
1484 0, 2, 1, 4, 6, 3, 5, 14, 12, 13, 11, 7, 9, 8, 10, 15, 16, 17, 19, 18, 25, 27, 24, 26, 21, 23, 20, 22, 35, 33, 34, 32, 28, 30, 29, 31, 41, 43, 40, 42, 37,
1485 39, 36, 38, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 63, 62, 60, 61, 65, 67, 64, 66, 71, 70, 68, 69, 73, 75, 72, 74, 79, 78, 76,
1486 77, 83, 82, 80, 81, 85, 87, 84, 86, 91, 90, 88, 89, 93, 95, 92, 94, 96, 102, 104, 101, 103, 98, 100, 97, 99, 106, 105, 108, 110, 107, 109, 116, 118,
1487 115, 117, 112, 114, 111, 113, 120, 119, 122, 124, 121, 123, 127, 128, 126, 125, 130, 129, 131, 133, 134, 135, 132, 137, 138, 139, 136, 143, 142, 140,
1493 0, 2, 1, 5, 3, 6, 4, 11, 13, 12, 14, 10, 8, 9, 7, 15, 16, 17, 19, 18, 26, 24, 27, 25, 22, 20, 23, 21, 32, 34, 33, 35, 31, 29, 30, 28, 42, 40, 43, 41, 38,
1494 36, 39, 37, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 62, 63, 61, 60, 66, 64, 67, 65, 70, 71, 69, 68, 74, 72, 75, 73, 78, 79, 77,
1495 76, 82, 83, 81, 80, 86, 84, 87, 85, 90, 91, 89, 88, 94, 92, 95, 93, 96, 103, 101, 104, 102, 99, 97, 100, 98, 106, 105, 109, 107, 110, 108, 117, 115,
1496 118, 116, 113, 111, 114, 112, 120, 119, 123, 121, 124, 122, 128, 127, 125, 126, 130, 129, 131, 135, 132, 133, 134, 139, 136, 137, 138, 142, 143, 141,
1518 delete UGMIt->second;
1594 Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
1595 Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
1597 Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
1604 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1605 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1618 {4, 6, -1, -1}, {2, 8, -1, -1}, {6, 8, -1, -1}, {4, 8, -1, -1}, {2, 6, -1, -1}, {2, 4, -1, -1},
1619 {4, 6, 4, 2}, {6, 4, 6, 2}, {4, 6, 4, 8}, {6, 4, 6, 8}, {8, 2, 8, 4}, {8, 2, 8, 6}, {2, 8, 2, 4}, {2, 8, 2, 6},
1621 {4, 6, 2, 8}, {1, 9, 3, 7},
1623 {3, 7, -1, -1}, {1, 9, -1, -1}, {7, 6, -1, -1}, {4, 9, -1, -1}, {1, 6, -1, -1}, {4, 3, -1, -1}, {3, 8, -1, -1}, {1, 8, -1, -1}, {2, 9, -1, -1},
1625 {4, 6, 4, 3}, {6, 4, 6, 1}, {4, 6, 4, 9}, {6, 4, 6, 7}, {8, 2, 8, 1}, {8, 2, 8, 3}, {2, 8, 2, 7}, {2, 8, 2, 9}, {9, 1, 9, 2}, {7, 3, 7, 2}, {3, 7, 3, 8}, {1, 9, 1, 8}, {9, 1, 9, 4}, {7, 3, 7, 6}, {3, 7, 3, 4}, {1, 9, 1, 6},
1628 {1, 9, 2, 8}, {2, 8, 3, 7}, {4, 6, 3, 7}, {1, 9, 4, 6},
1629 {2, 8, 4, 6}, {4, 6, 2, 8}, {3, 7, 1, 9}, {1, 9, 3, 7}, {2, 8, 1, 9}, {2, 8, 3, 7}, {3, 7, 2, 8}, {1, 9, 2, 8}, {4, 6, 3, 7}, {4, 6, 1, 9}, {1, 9, 4, 6}, {3, 7, 4, 6},
1630 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1631 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1},
1632 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1633 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1634 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1636 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1637 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1638 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1639 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1640 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1},
1641 {4, 6, -1, -1}, {2, 8, -1, -1},
1643 {8, 1, 8, 3}, {4, 3, 4, 9}, {2, 9, 2, 7}, {6, 7, 6, 1}, {9, 4, 9, 2}, {7, 2, 7, 6}, {1, 6, 1, 8}, {3, 8, 3, 4},
1645 {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1}, {1, 9, -1, -1},
1647 {4, 6, -1, -1}, {2, 8, -1, -1},
1652 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1653 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1654 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1655 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1658 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1659 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1660 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1662 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1663 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1664 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1666 {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn},
1668 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1669 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1670 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1671 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1672 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1673 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1674 {
Connection,
Signal,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1675 {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1676 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1677 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1678 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1679 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1680 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1682 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1683 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1684 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1685 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1686 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1687 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1688 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1689 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1693 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1694 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1695 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1701 for(
int x = 0; x < 17; x++)
1703 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1705 FixedTrackPiece[17] =
TFixedTrackPiece(17, TrackTypeArray[17], Links[17], Configs[17], 0, 0);
1709 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1715 ExistingGraphicLoaded(false), Width(16), Height(16)
1727 ExistingGraphicLoaded(false), Width(WidthIn), Height(HeightIn)
1765 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalScreenGraphic()");
1769 throw Exception(
"Overlay not 16x16 in TGraphicElement::LoadOriginalScreenGraphic()");
1773 throw Exception(
"Source not set in TGraphicElement::LoadOriginalScreenGraphic()");
1777 throw Exception(
"ExistingGraphicLoaded in TGraphicElement::LoadOriginalScreenGraphic()");
1800 AnsiString(VOffset) +
"," + AnsiString(WidthIn) +
"," + AnsiString(HeightIn));
1803 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalExistingGraphic()");
1807 throw Exception(
"Source not set in TGraphicElement::LoadOriginalExistingGraphic()");
1811 throw Exception(
"ScreenGraphicLoaded in TGraphicElement::LoadOriginalExistingGraphic()");
1845 throw Exception(
"Overlay not loaded in TGraphicElement::PlotOverlay()");
1866 throw Exception(
"Original not loaded in TGraphicElement::PlotOriginal()");
1880 bool TrackPresent =
false;
1894 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1898 TrackPresent =
true;
1903 return(!TrackPresent);
1911 bool TrackPresent =
false;
1920 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1924 TrackPresent =
true;
1930 return(!TrackPresent);
1935 void TTrack::EraseTrackElement(
int Caller,
int HLocInput,
int VLocInput,
int &ErasedTrackVectorPosition,
bool &TrackEraseSuccessfulFlag,
bool InternalChecks)
1938 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
1939 TrackEraseSuccessfulFlag =
false;
1944 ErasedTrackVectorPosition = -1;
1945 AnsiString SName =
"", ErrorString;
1947 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
1953 TrackMapKeyPair.first = HLocInput;
1954 TrackMapKeyPair.second = VLocInput;
1955 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
1966 if(ErrorString !=
"")
1968 throw Exception(ErrorString +
" for EraseTrackElement 1");
1992 ErasedTrackVectorPosition = VecPos;
1993 TrackEraseSuccessfulFlag =
true;
1999 unsigned int VecPos;
2000 InactiveTrackMapKeyPair.first = HLocInput;
2001 InactiveTrackMapKeyPair.second = VLocInput;
2006 VecPos = InactiveTrack2MultiMapIterator->second;
2011 if(ErrorString !=
"")
2013 throw Exception(ErrorString +
" for EraseTrackElement 2A");
2023 TrackEraseSuccessfulFlag =
true;
2044 VecPos = InactiveTrack2MultiMapIterator->second;
2049 if(ErrorString !=
"")
2051 throw Exception(ErrorString +
" for EraseTrackElement 2B");
2075 if(TrackEraseSuccessfulFlag)
2097 AnsiString(HLocInput) +
"," + AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2098 bool PlatAllowedFlag =
false;
2100 TrackLinkingRequiredFlag =
false;
2112 LocationNameEntry.first =
"";
2120 TempTrackElement.
HLoc = HLocInput;
2121 TempTrackElement.
VLoc = VLocInput;
2147 else if(Aspect == 1)
2151 else if(Aspect == 2)
2155 else if(Aspect == 3)
2164 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2167 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2169 if(InactiveFoundFlag)
2173 NonStationOrLevelCrossingPresent =
true;
2177 NonStationOrLevelCrossingPresent =
true;
2181 PlatformPresent =
true;
2192 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2200 PlatAllowedFlag =
true;
2204 PlatAllowedFlag =
true;
2208 PlatAllowedFlag =
true;
2212 PlatAllowedFlag =
true;
2216 TrackLinkingRequiredFlag =
true;
2244 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1048, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2245 (!FoundFlag && !InactiveFoundFlag))
2248 TrackLinkingRequiredFlag =
true;
2280 TrackLinkingRequiredFlag =
true;
2292 else if(FoundFlag || InactiveFoundFlag)
2311 bool BothPointFillets =
true;
2326 TrackLinkingRequiredFlag =
true;
2340 bool InternalChecks)
2344 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2345 bool PlatAllowedFlag =
false;
2347 TrackLinkingRequiredFlag =
false;
2350 LocationNameEntry.first =
"";
2356 TempTrackElement.
HLoc = HLocInput;
2357 TempTrackElement.
VLoc = VLocInput;
2358 for(
int x = 0; x < 4; x++)
2364 TempTrackElement.
Conn[x] = -1;
2368 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2379 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2381 if(InactiveFoundFlag)
2385 NonStationOrLevelCrossingPresent =
true;
2389 NonStationOrLevelCrossingPresent =
true;
2393 PlatformPresent =
true;
2404 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2412 PlatAllowedFlag =
true;
2416 PlatAllowedFlag =
true;
2420 PlatAllowedFlag =
true;
2424 PlatAllowedFlag =
true;
2428 TrackLinkingRequiredFlag =
true;
2459 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1055, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2460 (!FoundFlag && !InactiveFoundFlag))
2463 TrackLinkingRequiredFlag =
true;
2498 TrackLinkingRequiredFlag =
true;
2510 else if(FoundFlag || InactiveFoundFlag)
2529 bool BothPointFillets =
true;
2544 TrackLinkingRequiredFlag =
true;
2574 ShowMessage(
"Gaps must be set before track can be validated");
2584 throw Exception(
"Error, gaps unset when TryToConnectTrack called");
2595 if(!
LinkTrack(1, LocError, HLoc, VLoc,
false))
2612 ShowMessage(
"Error in RepositionAndMapTrack during TryToConnectTrack. Railway file is corrupt, further use may cause a system crash");
2619 if(!
LinkTrack(2, LocError, HLoc, VLoc,
true))
2643 std::pair<AnsiString, char>TempMapPair;
2651 TempMapPair.second =
'x';
2661 AnsiString Name =
"";
2662 typedef std::list<AnsiString> TNoPlatsList;
2663 TNoPlatsList::iterator NPLIt;
2664 TNoPlatsList NoPlatsList;
2665 typedef std::list<AnsiString> TLocNameList;
2666 TLocNameList LocNameList;
2671 LocNameList.push_back(LNMMIt->first);
2674 LocNameList.unique();
2675 for(TLocNameList::iterator LNLIt = LocNameList.begin(); LNLIt != LocNameList.end(); LNLIt++)
2679 if(MMRange.first == MMRange.second)
2685 if((LNMMIt->second) < 0)
2699 TempIt = MMRange.second;
2700 if(LNMMIt == --TempIt)
2702 NoPlatsList.push_back(Name);
2706 if(!NoPlatsList.empty())
2708 AnsiString NoPlatsAnsiList =
"";
2709 for(NPLIt = NoPlatsList.begin(); NPLIt != NoPlatsList.end(); NPLIt++)
2711 NoPlatsAnsiList += *NPLIt +
'\n';
2715 if(NoPlatsList.size() > 1)
2717 ShowMessage(
"Please note: the following locations have no platforms, trains won't be able to stop or pass there:-\n\n" + NoPlatsAnsiList +
"\nThis message will not be shown again.");
2721 ShowMessage(
"Please note: the following location has no platforms, trains won't be able to stop or pass there:-\n\n" + NoPlatsAnsiList +
"\nThis message will not be shown again.");
2736 int NewHLoc, NewVLoc;
2737 bool ConnectionFoundFlag, LinkFoundFlag;
2739 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2741 for(
unsigned int y = 0; y < 4; y++)
2759 ConnectionFoundFlag =
false;
2760 for(
unsigned int z = 0; z <
TrackVector.size(); z++)
2766 ConnectionFoundFlag =
true;
2768 LinkFoundFlag =
false;
2769 for(
unsigned int a = 0; a < 4; a++)
2773 LinkFoundFlag =
true;
2789 if(!ConnectionFoundFlag)
2864 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2881 bool UnsetGaps =
false;
2888 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2892 for(
unsigned int y = 0; y < 4; y++)
2904 for(
unsigned int y = 0; y < 4; y++)
2914 for(
unsigned int y = 1; y < 4; y++)
2923 for(
unsigned int y = 0; y < 4; y++)
2936 for(
unsigned int y = 0; y < 4; y++)
2964 int NumberOfActiveElements = 0;
2966 GraphicsFollow =
false;
2970 if(MarkerString[MarkerString.Length()] ==
'1')
2972 GraphicsFollow =
true;
2974 for(
int x = 0; x < NumberOfActiveElements; x++)
2980 TrackElement.
HLoc = TempInt;
2982 TrackElement.
VLoc = TempInt;
2988 TrackElement.
Conn[0] = TempInt;
3012 if((TempInt != -1) && (TempInt < 10))
3022 if((TempInt != -1) && (TempInt < 10))
3039 if(Marker[1] ==
'3')
3043 else if(Marker[1] ==
'2')
3047 else if(Marker[1] ==
'G')
3061 int NumberOfInactiveElements = 0;
3065 for(
int x = 0; x < NumberOfInactiveElements; x++)
3071 TrackElement.
HLoc = TempInt;
3073 TrackElement.
VLoc = TempInt;
3079 bool LocError =
false;
3108 for(
int x = 0; x < NumberOfGraphics; x++)
3119 bool FileError =
false;
3121 for(
int x = 0; x < NumberOfGraphics; x++)
3134 UGME.second =
new TPicture;
3135 UGME.second->LoadFromFile(
UGME.first);
3138 throw Exception(
"Map Insertion Error 2 - UserGraphicMap insertion failure for " + UGI.
FileName);
3145 catch(
const EInvalidGraphic &e)
3154 delete UGMIt->second;
3159 catch(
const Exception &e)
3168 delete UGMIt->second;
3176 bool FoundInMap =
false;
3195 UGME.second =
new TPicture;
3196 UGME.second->LoadFromFile(
UGME.first);
3199 throw Exception(
"Map Insertion Error 3 - UserGraphicMap insertion failure for " + UGI.
FileName);
3206 catch(
const EInvalidGraphic &e)
3215 delete UGMIt->second;
3220 catch(
const Exception &e)
3229 delete UGMIt->second;
3254 VecFile <<
"**Active elements**1" <<
'\0' <<
'\n';
3258 VecFile <<
"**Active elements**" <<
'\0' <<
'\n';
3260 for(
unsigned int x = 0; x < (
TrackVector.size()); x++)
3263 VecFile << x <<
'\n';
3264 VecFile << TrackElement.
SpeedTag <<
'\n';
3265 VecFile << TrackElement.
HLoc <<
'\n';
3266 VecFile << TrackElement.
VLoc <<
'\n';
3270 VecFile << TrackElement.
Conn[0] <<
'\n';
3274 VecFile << TrackElement.
Attribute <<
'\n';
3280 VecFile << int(1) <<
'\n';
3284 VecFile << int(0) <<
'\n';
3287 VecFile << TrackElement.
Length01 <<
'\n';
3288 VecFile << TrackElement.
Length23 <<
'\n';
3291 VecFile << TrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3298 VecFile <<
"3*****" <<
'\0' <<
'\n';
3302 VecFile <<
"2*****" <<
'\0' <<
'\n';
3306 VecFile <<
"G*****" <<
'\0' <<
'\n';
3310 VecFile <<
"4*****" <<
'\0' <<
'\n';
3315 VecFile <<
"******" <<
'\0' <<
'\n';
3320 VecFile <<
"**Inactive elements**" <<
'\0' <<
'\n';
3324 VecFile << x <<
'\n';
3325 VecFile << InactiveTrackElement.
SpeedTag <<
'\n';
3326 VecFile << InactiveTrackElement.
HLoc <<
'\n';
3327 VecFile << InactiveTrackElement.
VLoc <<
'\n';
3328 VecFile << InactiveTrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3329 VecFile <<
"******" <<
'\0' <<
'\n';
3344 GraphicsFollow =
false;
3346 if((NumberOfActiveElements < 0) || (NumberOfActiveElements > 1000000))
3352 AnsiString MarkerString;
3359 if(MarkerString[MarkerString.Length()] ==
'1')
3361 GraphicsFollow =
true;
3363 for(
int x = 0; x < NumberOfActiveElements; x++)
3371 int SpeedTag = TempInt;
3378 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3384 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3389 if((SpeedTag > 87) && (SpeedTag < 96))
3392 if((TempInt < -1) || (TempInt > 3))
3398 if((TempInt < -1) || (TempInt > 999999))
3404 if(((SpeedTag >= 7) && (SpeedTag <= 14)) || ((SpeedTag >= 28) && (SpeedTag <= 43)) || ((SpeedTag >= 132) && (SpeedTag <= 139)) ||
3405 ((SpeedTag >= 68) && (SpeedTag <= 75)))
3408 if((TempInt < -1) || (TempInt > 5))
3414 if((SpeedTag >= 68) && (SpeedTag <= 75))
3417 if((TempInt != 0) && (TempInt != 1))
3424 if((TempInt < -1) || (TempInt > 999999))
3430 if((TempInt < -1) || (TempInt > 999999))
3436 if((TempInt < -1) || (TempInt > 999999))
3442 if((TempInt < -1) || (TempInt > 999999))
3463 int NumberOfInactiveElements = 0;
3466 if(NumberOfInactiveElements < 0)
3476 for(
int x = 0; x < NumberOfInactiveElements; x++)
3490 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3496 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3523 if((NumberOfGraphics < 0) || (NumberOfGraphics > 100000))
3529 AnsiString FileName =
"", TempStr =
"";
3531 for(
int x = 0; x < NumberOfGraphics; x++)
3533 TPicture *TempPicture =
new TPicture;
3542 TempPicture->LoadFromFile(GraphicsPath +
"\\" + FileName);
3555 catch(
const EInvalidGraphic &e)
3560 for(
int y = x + 1; y < NumberOfGraphics; y++)
3566 ShowMessage(FileName +
3567 " has an incorrect file format, user graphics can't be loaded. Ensure that all user graphic files are valid with extension .bmp, .gif, .jpg, or .png");
3572 catch(
const Exception &e)
3577 for(
int y = x + 1; y < NumberOfGraphics; y++)
3583 ShowMessage(
"Unable to load user graphic files, ensure that " + FileName +
3584 " exists in the 'Graphics' folder and that it is has extension .bmp, .gif, .jpg, or .png.");
3602 for(
int x = 0; x < VecSize; x++)
3625 for(
int x = 0; x < VecSize; x++)
3647 for(
int x = 0; x < VecSize; x++)
3701 for(
int x = 0; x < VecSize; x++)
3759 PlotPoints(5, Next, Disp, BothPointFilletsAndBasicLCs);
3777 if(BothPointFilletsAndBasicLCs)
3852 Bitmap->Canvas->CopyMode = cmSrcCopy;
3854 Graphics::TBitmap *GraphicOutput;
4029 for(
int x = 0; x < 40; x++)
4058 Graphics::TBitmap *GraphicPtr;
4073 Graphics::TBitmap* SignalPlatformGraphic;
4106 if(OldTransparentColour !=
clB5G5R5)
4129 Bitmap->Canvas->CopyMode = cmSrcCopy;
4157 Bitmap->Canvas->CopyMode = cmSrcCopy;
4159 Graphics::TBitmap *GraphicOutput;
4169 if(BaseElement == 1)
4259 for(
int x = 0; x < 40; x++)
4288 Graphics::TBitmap *GraphicPtr;
4303 Graphics::TBitmap* SignalPlatformGraphic;
4364 for(
int x = 0; x < 40; x++)
4372 Graphics::TBitmap* SignalPlatformGraphic;
4393 if(OldTransparentColour !=
clB5G5R5)
4407 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4479 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4493 ShowMessage(
"Error - gap connected to a non-gap. Railway file is corrupt, further use may cause a system crash");
4519 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4544 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4574 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4608 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4645 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4660 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4689 for(TrackMapPtr =
TrackMap.begin(); TrackMapPtr !=
TrackMap.end(); TrackMapPtr++)
4696 throw Exception(
"Error - Map & Vector different sizes");
4698 unsigned int NonZeroCount = 0;
4700 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4709 throw Exception(
"Error - NewVector & NonZero TrackVector different sizes");
4715 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4719 TrackMapEntry.first = TrackMapKeyPair;
4720 TrackMapEntry.second = x;
4721 if(!(
TrackMap.insert(TrackMapEntry).second))
4723 throw Exception(
"Error - map insertion failure, TrackVector in error");
4727 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4729 for(
unsigned int y = 0; y < 4; y++)
4754 THVPair GapMapKeyPair, GapMapValuePair;
4757 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4763 GapMapEntry.first = GapMapKeyPair;
4766 throw Exception(
"Error - Gap connection == -1 Can't build GapMap");
4770 GapMapEntry.second = GapMapValuePair;
4773 GapMap.insert(GapMapEntry);
4786 bool CheckForLinks =
false;
4788 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4800 "Footbridge or underpass connection error. Each end must connect to a platform, concourse "
4801 "or other footbridge or underpass, and they can't connect to each other (i.e. a footbridge "
4802 "can't connect to an underpass or vice versa)");
4810 for(
unsigned int y = 0; y < 4; y++)
4812 CheckForLinks =
false;
4830 bool ConnectionFoundFlag;
4834 ShowMessage(
"Can't have a track element adjacent to a continuation exit");
4840 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
4849 if(ConnectionFoundFlag)
4853 bool LinkFoundFlag =
false;
4857 ShowMessage(
"Can't have an exit signal next to a level crossing - it can cause the train to foul the crossing in some circumstances");
4863 ShowMessage(
"Can't have points, crossover or signal next to buffers - need room for a train without fouling");
4869 ShowMessage(
"Can't have points, crossover, bridge or signal next to a continuation - it can cause route setting problems");
4877 ShowMessage(
"Can't have two same-direction signals adjacent to each other as there is no room for a train between them");
4883 ShowMessage(
"Signal facing a bridge - routes can't be truncated to this or other such signals.\n\nThis restriction can be removed or reinstated by pressing\nCTRL ALT 5. When removed this message will not be shown again.");
4890 ShowMessage(
"Can't have two level crossings adjacent to each other on the same track");
4894 CheckForLinks =
true;
4898 for(
unsigned int a = 0; a < 4; a++)
4907 LinkFoundFlag =
true;
4920 throw Exception(
"Error in final track linkage - invalid link");
4934 throw Exception(
"Error in final track linkage - connection not found");
4947 bool ConnErrorFlag =
false;
4949 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4953 ConnErrorFlag =
true;
4957 ConnErrorFlag =
true;
4961 ConnErrorFlag =
true;
4965 ConnErrorFlag =
true;
4973 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
4982 throw Exception(
"ConnError in LinkTrack - Final");
4986 throw Exception(
"ConnError in LinkTrack - Precheck");
4989 bool CLkErrorFlag =
false;
4991 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4995 CLkErrorFlag =
true;
4999 CLkErrorFlag =
true;
5003 CLkErrorFlag =
true;
5007 CLkErrorFlag =
true;
5015 throw Exception(
"CLkError in LinkTrack - Final");
5019 throw Exception(
"CLkError in LinkTrack - Precheck");
5023 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5053 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5069 for(
unsigned int y = 0; y < 4; y++)
5088 bool ConnectionFoundFlag;
5094 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
5103 if(ConnectionFoundFlag)
5106 bool LinkFoundFlag =
false;
5163 for(
unsigned int a = 0; a < 4; a++)
5172 LinkFoundFlag =
true;
5180 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - invalid link");
5190 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - connection not found");
5203 bool ConnErrorFlag =
false;
5205 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5209 ConnErrorFlag =
true;
5213 ConnErrorFlag =
true;
5217 ConnErrorFlag =
true;
5221 ConnErrorFlag =
true;
5229 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
5238 throw Exception(
"ConnError in LinkTrack - Final");
5242 throw Exception(
"ConnError in LinkTrack - Precheck");
5245 bool CLkErrorFlag =
false;
5247 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5251 CLkErrorFlag =
true;
5255 CLkErrorFlag =
true;
5259 CLkErrorFlag =
true;
5263 CLkErrorFlag =
true;
5271 throw Exception(
"CLkError in LinkTrack - Final");
5275 throw Exception(
"CLkError in LinkTrack - Precheck");
5279 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5308 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5324 for(
unsigned int y = 0; y < 4; y++)
5343 bool ConnectionFoundFlag =
false;
5345 if(ConnectionFoundFlag)
5349 bool LinkFoundFlag =
false;
5369 for(
unsigned int a = 0; a < 4; a++)
5378 LinkFoundFlag =
true;
5398 bool ConnErrorFlag =
false;
5400 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5404 ConnErrorFlag =
true;
5408 ConnErrorFlag =
true;
5412 ConnErrorFlag =
true;
5416 ConnErrorFlag =
true;
5424 bool CLkErrorFlag =
false;
5426 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5430 CLkErrorFlag =
true;
5434 CLkErrorFlag =
true;
5438 CLkErrorFlag =
true;
5442 CLkErrorFlag =
true;
5460 int Position1, Position2;
5466 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
5468 int HLoc1 = GapMapPtr->first.first;
5469 int VLoc1 = GapMapPtr->first.second;
5470 int HLoc2 = GapMapPtr->second.first;
5471 int VLoc2 = GapMapPtr->second.second;
5474 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
5478 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
5482 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
5486 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
5504 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
5505 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
5515 bool FoundFlag =
false;
5527 InactiveTrackMapKeyPair.first = TrackElement.
HLoc;
5528 InactiveTrackMapKeyPair.second = TrackElement.
VLoc;
5529 InactiveTrackMapEntry.first = InactiveTrackMapKeyPair;
5558 bool FoundFlag =
false;
5571 TrackMapKeyPair.first = TrackElement.
HLoc;
5572 TrackMapKeyPair.second = TrackElement.
VLoc;
5573 TrackMapEntry.first = TrackMapKeyPair;
5578 LocationNameEntry.second = -(int)(
TrackVector.size());
5618 TrackMapKeyPair.first = HLoc;
5619 TrackMapKeyPair.second = VLoc;
5620 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5630 return(TrackMapPtr->second);
5643 TrackMapKeyPair.first = HLoc;
5644 TrackMapKeyPair.second = VLoc;
5645 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5648 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5649 throw Exception(Message);
5667 MapKeyPair.first = HLoc;
5668 MapKeyPair.second = VLoc;
5669 MapPtr = Map.find(MapKeyPair);
5670 if(MapPtr == Map.end())
5672 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc) +
" in GetTrackElementFromAnyTrackMap";
5673 throw Exception(Message);
5678 return(Vector.at(MapPtr->second));
5688 THVPair InactiveTrackMapKeyPair;
5691 InactiveTrackMapKeyPair.first = HLoc;
5692 InactiveTrackMapKeyPair.second = VLoc;
5696 AnsiString Message =
"Inactive element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5697 throw Exception(Message);
5711 bool Present =
true;
5715 TrackMapKeyPair.first = HLoc;
5716 TrackMapKeyPair.second = VLoc;
5717 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5732 bool Present =
true;
5733 THVPair InactiveTrackMapKeyPair;
5736 InactiveTrackMapKeyPair.first = HLoc;
5737 InactiveTrackMapKeyPair.second = VLoc;
5755 THVPair InactiveTrackMapKeyPair;
5760 InactiveTrackMapKeyPair.first = HLoc;
5761 InactiveTrackMapKeyPair.second = VLoc;
5770 if(InactiveTrackRange.first == InactiveTrackRange.second)
5779 RetPair.first = InactiveTrackRange.first->second;
5780 RetPair.second = (--InactiveTrackRange.second)->second;
5793 AnsiString(DivergingPosition));
5804 if(((SpeedTag1 == 7) && (SpeedTag2 == 10)) ||
5805 ((SpeedTag1 == 10) && (SpeedTag2 == 7)) || ((SpeedTag1 == 8) && (SpeedTag2 == 9)) || ((SpeedTag1 == 9) && (SpeedTag2 == 8)) ||
5806 ((SpeedTag1 == 11) && (SpeedTag2 == 14)) ||
5807 ((SpeedTag1 == 14) && (SpeedTag2 == 11)) || ((SpeedTag1 == 12) && (SpeedTag2 == 13)) || ((SpeedTag1 == 13) && (SpeedTag2 == 12)) ||
5808 ((SpeedTag1 == 28) && (SpeedTag2 == 31)) ||
5809 ((SpeedTag1 == 31) && (SpeedTag2 == 28)) || ((SpeedTag1 == 29) && (SpeedTag2 == 30)) || ((SpeedTag1 == 30) && (SpeedTag2 == 29)) ||
5810 ((SpeedTag1 == 32) && (SpeedTag2 == 35)) ||
5811 ((SpeedTag1 == 35) && (SpeedTag2 == 32)) || ((SpeedTag1 == 33) && (SpeedTag2 == 34)) || ((SpeedTag1 == 34) && (SpeedTag2 == 33)) ||
5812 ((SpeedTag1 == 36) && (SpeedTag2 == 39)) ||
5813 ((SpeedTag1 == 39) && (SpeedTag2 == 36)) || ((SpeedTag1 == 37) && (SpeedTag2 == 38)) || ((SpeedTag1 == 38) && (SpeedTag2 == 37)) ||
5814 ((SpeedTag1 == 40) && (SpeedTag2 == 43)) ||
5815 ((SpeedTag1 == 43) && (SpeedTag2 == 40)) || ((SpeedTag1 == 41) && (SpeedTag2 == 42)) || ((SpeedTag1 == 42) && (SpeedTag2 == 41)))
5849 throw Exception(
"Error, Wrong track type in PlotGap");
5851 if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] > -1))
5855 else if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] == -1))
5859 if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] > -1))
5863 else if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] == -1))
5867 if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] > -1))
5871 else if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] == -1))
5875 if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] > -1))
5879 else if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] == -1))
5883 if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] > -1))
5887 else if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] == -1))
5891 if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] > -1))
5895 else if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] == -1))
5899 if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] > -1))
5903 else if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] == -1))
5907 if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] > -1))
5911 else if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] == -1))
5925 throw Exception(
"Error, Wrong track type in PlotPoints");
5936 else if(TrackElement.
SpeedTag < 132)
5954 else if(TrackElement.
SpeedTag < 132)
5987 throw Exception(
"Error, Wrong track type in PlotSignal");
5989 for(
int x = 0; x < 40; x++)
6060 for(
int x = 0; x < 40; x++)
6067 Graphics::TBitmap* SignalPlatformGraphic;
6154 while(
IsLCAtHV(0, HLoc, (VLoc + UpStep)))
6162 while(
IsLCAtHV(1, HLoc, (VLoc + DownStep)))
6170 while(
IsLCAtHV(2, (HLoc + LeftStep), VLoc))
6178 while(
IsLCAtHV(3, (HLoc + RightStep), VLoc))
6194 while(
IsLCAtHV(51, HLoc, (VLoc + UpStep)))
6202 while(
IsLCAtHV(52, HLoc, (VLoc + DownStep)))
6210 while(
IsLCAtHV(53, (HLoc + LeftStep), VLoc))
6218 while(
IsLCAtHV(54, (HLoc + RightStep), VLoc))
6251 while(
IsLCAtHV(55, HLoc, (VLoc + UpStep)))
6263 while(
IsLCAtHV(56, HLoc, (VLoc + DownStep)))
6275 while(
IsLCAtHV(57, (HLoc + LeftStep), VLoc))
6287 while(
IsLCAtHV(58, (HLoc + RightStep), VLoc))
6329 throw Exception(
"Error, Wrong track type in PlotAndLowerLevelCrossingBarriers");
6331 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6333 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndLowerLevelCrossingBarriers");
6336 if(BaseElementSpeedTag == 1)
6340 while(
IsLCAtHV(5, HLoc, (VLoc + UpStep)))
6347 while(
IsLCAtHV(6, HLoc, (VLoc + DownStep)))
6355 Graphics::TBitmap *RouteGraphic;
6357 if(TypeOfRoute == 1)
6361 else if(TypeOfRoute == 0)
6367 RouteGraphic = BaseGraphic;
6374 if(UpStep == DownStep)
6377 Disp->
PlotOutput(133, HLoc * 16, VLoc * 16, RouteGraphic);
6387 else if((DownStep - UpStep) == 1)
6392 Disp->
PlotOutput(136, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6402 Disp->
PlotOutput(139, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6415 Disp->
PlotOutput(196, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6425 Disp->
PlotOutput(199, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6441 Disp->
PlotOutput(142, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6451 Disp->
PlotOutput(145, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6461 else if(DownStep == 0)
6464 Disp->
PlotOutput(202, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6474 Disp->
PlotOutput(205, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6487 Disp->
PlotOutput(208, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6497 Disp->
PlotOutput(211, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6507 for(
int x = (UpStep + 1); x < DownStep; x++)
6512 Disp->
PlotOutput(148, HLoc * 16, (VLoc + x) * 16, RouteGraphic);
6516 Disp->
PlotOutput(213, HLoc * 16, (VLoc + x) * 16, BaseGraphic);
6537 while(
IsLCAtHV(7, (HLoc + LStep), VLoc))
6544 while(
IsLCAtHV(8, (HLoc + RStep), VLoc))
6550 Graphics::TBitmap *RouteGraphic;
6552 if(TypeOfRoute == 1)
6556 else if(TypeOfRoute == 0)
6562 RouteGraphic = BaseGraphic;
6571 Disp->
PlotOutput(151, HLoc * 16, VLoc * 16, RouteGraphic);
6581 else if((RStep - LStep) == 1)
6586 Disp->
PlotOutput(154, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6596 Disp->
PlotOutput(157, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6609 Disp->
PlotOutput(215, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6619 Disp->
PlotOutput(218, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6635 Disp->
PlotOutput(160, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6645 Disp->
PlotOutput(163, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6658 Disp->
PlotOutput(221, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6668 Disp->
PlotOutput(224, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6681 Disp->
PlotOutput(227, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6691 Disp->
PlotOutput(230, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6701 for(
int x = (LStep + 1); x < RStep; x++)
6706 Disp->
PlotOutput(166, (HLoc + x) * 16, VLoc * 16, RouteGraphic);
6710 Disp->
PlotOutput(232, (HLoc + x) * 16, VLoc * 16, BaseGraphic);
6734 AnsiString(HLoc) +
"," + AnsiString(VLoc));
6737 throw Exception(
"Error, Wrong track type in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
6739 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6741 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
6744 if(BaseElementSpeedTag == 1)
6748 while(
IsLCAtHV(30, HLoc, (VLoc + UpStep)))
6755 while(
IsLCAtHV(31, HLoc, (VLoc + DownStep)))
6761 if(UpStep == DownStep)
6772 else if((DownStep - UpStep) == 1)
6791 for(
int x = (UpStep + 1); x < DownStep; x++)
6800 for(
int x = (UpStep + 1); x < DownStep; x++)
6807 for(
int x = UpStep; x <= DownStep; x++)
6820 while(
IsLCAtHV(32, (HLoc + LStep), VLoc))
6827 while(
IsLCAtHV(33, (HLoc + RStep), VLoc))
6844 else if((RStep - LStep) == 1)
6863 for(
int x = (LStep + 1); x < RStep; x++)
6872 for(
int x = (LStep + 1); x < RStep; x++)
6879 for(
int x = LStep; x <= RStep; x++)
6898 throw Exception(
"Error, Wrong track type in PlotAndRaiseLevelCrossingBarriers");
6900 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6902 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndRaiseLevelCrossingBarriers");
6905 if(BaseElementSpeedTag == 1)
6909 while(
IsLCAtHV(10, HLoc, (VLoc + UpStep)))
6916 while(
IsLCAtHV(11, HLoc, (VLoc + DownStep)))
6922 for(
int x = UpStep; x < (DownStep + 1); x++)
6937 while(
IsLCAtHV(12, (HLoc + LStep), VLoc))
6944 while(
IsLCAtHV(13, (HLoc + RStep), VLoc))
6950 for(
int x = LStep; x < (RStep + 1); x++)
6969 AnsiString(HLoc) +
"," + AnsiString(VLoc));
6972 throw Exception(
"Error, Wrong track type in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
6974 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6976 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
6981 if(BaseElementSpeedTag == 1)
6985 while(
IsLCAtHV(35, HLoc, (VLoc + UpStep)))
6992 while(
IsLCAtHV(36, HLoc, (VLoc + DownStep)))
6998 for(
int x = UpStep; x <= DownStep; x++)
7012 while(
IsLCAtHV(37, (HLoc + LStep), VLoc))
7019 while(
IsLCAtHV(38, (HLoc + RStep), VLoc))
7025 for(
int x = LStep; x <= RStep; x++)
7041 Graphics::TBitmap *RouteGraphic;
7044 if(BaseElementSpeedTag == 1)
7046 if(TypeOfRoute == 1)
7050 else if(TypeOfRoute == 0)
7056 RouteGraphic = BaseGraphic;
7060 RouteGraphic = BaseGraphic;
7066 if(TypeOfRoute == 1)
7070 else if(TypeOfRoute == 0)
7076 RouteGraphic = BaseGraphic;
7080 RouteGraphic = BaseGraphic;
7085 while(
IsLCAtHV(14, HLoc, (VLoc + UpStep)))
7090 Disp->
PlotOutput(175, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
7094 Disp->
PlotOutput(234, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
7101 while(
IsLCAtHV(15, HLoc, (VLoc + DownStep)))
7104 Disp->
PlotOutput(177, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
7109 while(
IsLCAtHV(16, (HLoc + LeftStep), VLoc))
7114 Disp->
PlotOutput(235, (HLoc + LeftStep) * 16, VLoc * 16, RouteGraphic);
7118 Disp->
PlotOutput(236, (HLoc + LeftStep) * 16, VLoc * 16, BaseGraphic);
7125 while(
IsLCAtHV(17, (HLoc + RightStep), VLoc))
7128 Disp->
PlotOutput(238, (HLoc + RightStep) * 16, VLoc * 16, BaseGraphic);
7253 throw Exception(
"Element not found in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7257 throw Exception(
"Element not a level crossing in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7288 "," + AnsiString(VLoc));
7292 int DummyRouteNumber;
7294 TrainPresent =
false;
7298 while(
IsLCAtHV(25, HLoc, (VLoc + UpStep)))
7300 TrackMapKeyPair.first = HLoc;
7301 TrackMapKeyPair.second = VLoc + UpStep;
7302 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7311 TrainPresent =
true;
7325 while(
IsLCAtHV(26, HLoc, (VLoc + DownStep)))
7327 TrackMapKeyPair.first = HLoc;
7328 TrackMapKeyPair.second = VLoc + DownStep;
7329 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7338 TrainPresent =
true;
7352 while(
IsLCAtHV(27, (HLoc + LeftStep), VLoc))
7354 TrackMapKeyPair.first = HLoc + LeftStep;
7355 TrackMapKeyPair.second = VLoc;
7356 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7365 TrainPresent =
true;
7379 while(
IsLCAtHV(28, (HLoc + RightStep), VLoc))
7381 TrackMapKeyPair.first = HLoc + RightStep;
7382 TrackMapKeyPair.second = VLoc;
7383 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7392 TrainPresent =
true;
7412 for(
unsigned int x = 0; x < SearchVector.size(); x++)
7429 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7432 throw Exception(
"PlotSmallFlashingLinkedLevelCrossings");
7438 while(
IsLCAtHV(61, HLoc, (VLoc + UpStep)))
7445 while(
IsLCAtHV(62, HLoc, (VLoc + DownStep)))
7451 for(
int x = UpStep; x <= DownStep; x++)
7458 while(
IsLCAtHV(63, (HLoc + LStep), VLoc))
7465 while(
IsLCAtHV(64, (HLoc + RStep), VLoc))
7471 for(
int x = LStep; x <= RStep; x++)
7487 throw Exception(
"Error, Wrong track type in GetFilletGraphic");
7494 else if(TrackElement.
SpeedTag < 132)
7512 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
7529 AnsiString(ScreenPosV));
7544 AnsiString(ScreenPosV));
7555 AnsiString(VPosTrue));
7569 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
7581 throw Exception(
"CheckMapAndTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
7582 " in TrackMap, Caller=" + (AnsiString)Caller);
7584 if(MapVecPos != (
int)a)
7586 throw Exception(
"CheckMapAndTrack Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
7587 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)MapVecPos +
" TrackVectorPos value=" + (AnsiString)a +
" Caller=" +
7588 (AnsiString)Caller);
7594 throw Exception(
"CheckMapAndTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
7595 " Caller=" + (AnsiString)Caller);
7615 throw Exception(
"CheckMapAndInactiveTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
7616 " in InactiveMap, Caller=" + (AnsiString)Caller);
7618 if((InactivePair.first != a) && (InactivePair.second != a))
7620 throw Exception(
"CheckMapAndInactiveTrack Error - InactiveMapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
7621 (AnsiString)CheckElement.
VLoc +
" Inactive Map values=" + (AnsiString)InactivePair.first +
" and " + (AnsiString)InactivePair.second +
7622 " InactiveTrackVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
7627 throw Exception(
"CheckMapAndInactiveTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
7628 " Caller=" + (AnsiString)Caller);
7638 int Position1, Position2;
7644 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
7646 int HLoc1 = GapMapPtr->first.first;
7647 int VLoc1 = GapMapPtr->first.second;
7648 int HLoc2 = GapMapPtr->second.first;
7649 int VLoc2 = GapMapPtr->second.second;
7652 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
7656 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
7660 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
7664 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
7668 unsigned int GapCount = 0;
7670 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
7678 if((
GapMap.size() * 2) != GapCount)
7680 throw Exception(
"GapMap Error - Map Size * 2 =" + (AnsiString)(
GapMap.size() * 2) +
" GapCount=" + (AnsiString)GapCount +
" Caller=" +
7681 (AnsiString)Caller);
7691 if((TrackElement.
HLoc == -2000000000) || (TrackElement.
VLoc == -2000000000))
7695 throw Exception(
"Error - TrackFinished with erase element still present");
7700 AnsiString IDString;
7702 if(TrackElement.
HLoc < 0)
7704 IDString =
"N" + AnsiString(abs(TrackElement.
HLoc)) +
"-";
7708 IDString = AnsiString(TrackElement.
HLoc) +
"-";
7710 if(TrackElement.
VLoc < 0)
7712 IDString +=
"N" + AnsiString(abs(TrackElement.
VLoc));
7716 IDString += AnsiString(TrackElement.
VLoc);
7730 for(
int x = 1; x < String.Length() + 1; x++)
7732 if(String.IsDelimiter(
"-", x))
7737 if(x == String.Length())
7741 ShowMessage(
"Error in track element identifier: <" + String +
"> - no delimiter");
7751 ShowMessage(
"Error in track element identifier: <" + String +
"> - No Horizontal value");
7756 if(DelimPos == String.Length())
7760 ShowMessage(
"Error in track element identifier <" + String +
"> - No Vertical value");
7765 if((String[String.Length()] <
'0') || (String[String.Length()] >
'9'))
7769 ShowMessage(
"Error in track element identifier <" + String +
"> - Last value is not a number");
7776 if(String.SubString(1, 1) !=
"N")
7778 for(
int x = 1; x < DelimPos; x++)
7780 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7784 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
7791 if(String.SubString(1, 1) ==
"N")
7793 for(
int x = 2; x < DelimPos; x++)
7795 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7799 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
7806 if(String.SubString(1, 1) ==
"N")
7808 HLoc = -(String.SubString(2, DelimPos - 2).ToInt());
7812 HLoc = String.SubString(1, DelimPos - 1).ToInt();
7814 if(String.SubString(DelimPos + 1, 1) !=
"N")
7816 for(
int x = DelimPos + 1; x < String.Length() + 1; x++)
7818 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7822 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
7829 if(String.SubString(DelimPos + 1, 1) ==
"N")
7831 for(
int x = DelimPos + 2; x < String.Length() + 1; x++)
7833 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7837 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
7844 if(String.SubString(DelimPos + 1, 1) ==
"N")
7846 VLoc = -(String.SubString(DelimPos + 2, String.Length() - DelimPos - 1).ToInt());
7850 VLoc = String.SubString(DelimPos + 1, String.Length() - DelimPos).ToInt();
7855 TrackMapPtr =
TrackMap.find(HVPair);
7860 ShowMessage(
"No track element corresponding to track element identifier: <" + String +
">");
7866 return(TrackMapPtr->second);
7877 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
7878 int HLoc = TrackElement.
HLoc;
7879 int VLoc = TrackElement.
VLoc;
7982 AnsiString(SpeedTag));
7993 if(HVRange.first == HVRange.second)
8000 HVIt1 = HVRange.first;
8005 if(--HVRange.second != HVRange.first)
8007 HVIt2 = HVRange.second;
8011 HVIt2->second).
SpeedTag == SpeedTag)))
8031 AnsiString(SpeedTag));
8097 AnsiString TestString1, TestString2;
8102 throw Exception(
"LNPendingList size not 1 on entry");
8104 int CurrentElementNumber;
8110 int H = CurrentElement->HLoc;
8111 int V = CurrentElement->VLoc;
8112 int Tag = CurrentElement->SpeedTag;
8118 for(
int x = 0; x < 25; x++)
8128 for(
int x = 0; x < 25; x++)
8138 for(
int x = 0; x < 25; x++)
8148 for(
int x = 0; x < 25; x++)
8158 for(
int x = 0; x < 28; x++)
8168 for(
int x = 0; x < 8; x++)
8178 for(
int x = 0; x < 8; x++)
8188 for(
int x = 0; x < 4; x++)
8198 for(
int x = 0; x < 8; x++)
8208 for(
int x = 0; x < 8; x++)
8221 if(CurrentElementNumber > -1)
8226 if((ExistingName !=
"") && (ExistingName != LocationName))
8242 AddName(1, CurrentElement, LocationName);
8246 LNDone2MultiMapEntry.first = HVPair;
8257 bool FoundFlag, ErasedFlag =
false;
8259 if(SNRange.first != SNRange.second)
8263 for(SNIterator = SNRange.second; SNIterator != SNRange.first; SNIterator--)
8270 TVIt->LocationName =
"";
8271 TVIt->ActiveTrackElementName =
"";
8304 std::pair<AnsiString, char>TempMapPair;
8312 TempMapPair.second =
'x';
8330 AnsiString(SpeedTag));
8340 if((SpeedTag == 129) || (SpeedTag == 130) || (SpeedTag == 145) || (SpeedTag == 146))
8347 int MapPos = -1 - Position;
8351 FoundElement = MapPos;
8367 FoundElement = IMPair.first;
8376 FoundElement = IMPair.second;
8397 AnsiString OldName = TrackElement->LocationName, ErrorString;
8399 TrackElement->LocationName = Name;
8400 int HLoc = TrackElement->HLoc;
8401 int VLoc = TrackElement->VLoc;
8415 if(ErrorString !=
"")
8417 throw Exception(ErrorString +
" in AddName for OldName == " + OldName);
8441 if(LNDone2MultiMapIterator->second == MapPos)
8468 if(*LNPendingListIterator == MapPos)
8541 if(NameBeingChecked !=
"")
8547 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
8555 NameBeingChecked = LNMMRg.second->first;
8557 if(NameBeingChecked !=
"")
8563 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
8584 if(LNMMIt->second < 0)
8594 HVPairsLinkedMap.insert(std::pair<THVPair, bool>(HVPair,
false));
8602 std::list<THVPair> HVLinkedList;
8605 HVPairsLinkedMap.begin()->second =
true;
8606 HVLinkedList.push_back(HVPairsLinkedMap.begin()->first);
8609 THVPair HVPairUnderExamination;
8610 THVPairsLinkedMap::iterator HVPLMIt;
8612 while(!HVLinkedList.empty())
8614 HVPairUnderExamination = HVLinkedList.front();
8615 HVLinkedList.pop_front();
8616 HVPairNew.first = HVPairUnderExamination.first;
8617 HVPairNew.second = HVPairUnderExamination.second - 1;
8618 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8619 if(HVPLMIt != HVPairsLinkedMap.end())
8621 if(!HVPLMIt->second)
8623 HVLinkedList.push_back(HVPLMIt->first);
8625 HVPLMIt->second =
true;
8627 HVPairNew.first = HVPairUnderExamination.first - 1;
8628 HVPairNew.second = HVPairUnderExamination.second;
8629 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8630 if(HVPLMIt != HVPairsLinkedMap.end())
8632 if(!HVPLMIt->second)
8634 HVLinkedList.push_back(HVPLMIt->first);
8636 HVPLMIt->second =
true;
8638 HVPairNew.first = HVPairUnderExamination.first;
8639 HVPairNew.second = HVPairUnderExamination.second + 1;
8640 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8641 if(HVPLMIt != HVPairsLinkedMap.end())
8643 if(!HVPLMIt->second)
8645 HVLinkedList.push_back(HVPLMIt->first);
8647 HVPLMIt->second =
true;
8649 HVPairNew.first = HVPairUnderExamination.first + 1;
8650 HVPairNew.second = HVPairUnderExamination.second;
8651 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8652 if(HVPLMIt != HVPairsLinkedMap.end())
8654 if(!HVPLMIt->second)
8656 HVLinkedList.push_back(HVPLMIt->first);
8658 HVPLMIt->second =
true;
8663 for(THVPairsLinkedMap::iterator HVPLMIt = HVPairsLinkedMap.begin(); HVPLMIt != HVPairsLinkedMap.end(); HVPLMIt++)
8665 if(!HVPLMIt->second)
8684 if(LocationName ==
"")
8695 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8702 ActiveTrackElementNameMapEntry.second = 0;
8724 bool FoundFlag, ErasedFlag =
false;
8728 if(SNRange.first != SNRange.second)
8731 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
8734 TVIt->LocationName =
"";
8735 TVIt->ActiveTrackElementName =
"";
8769 AnsiString(VLoc) +
"," + AnsiString(SpeedTag));
8771 AnsiString LocationName;
8780 if(LocationName !=
"")
8788 if(LocationName !=
"")
8802 if(LocationName !=
"")
8804 int ModifiedPosition = -1 - Position;
8813 for(
int x = 0; x < 25; x++)
8823 else if(SpeedTag == 77)
8825 for(
int x = 0; x < 25; x++)
8835 else if(SpeedTag == 78)
8837 for(
int x = 0; x < 25; x++)
8847 else if(SpeedTag == 79)
8849 for(
int x = 0; x < 25; x++)
8859 else if(SpeedTag == 96)
8861 for(
int x = 0; x < 28; x++)
8871 else if(SpeedTag == 129)
8873 for(
int x = 0; x < 8; x++)
8883 else if(SpeedTag == 130)
8885 for(
int x = 0; x < 8; x++)
8895 else if(SpeedTag == 145)
8897 for(
int x = 0; x < 8; x++)
8907 else if(SpeedTag == 146)
8909 for(
int x = 0; x < 8; x++)
8919 else if(SpeedTag == 131)
8921 for(
int x = 0; x < 4; x++)
8944 AnsiString(SpeedTag));
8956 if(TempElement->LocationName !=
"")
8958 LocationName = TempElement->LocationName;
8959 FoundElement = IMPair.first;
8967 if(TempElement->LocationName !=
"")
8969 LocationName = TempElement->LocationName;
8970 FoundElement = IMPair.second;
8982 if(TempElement->LocationName !=
"")
8984 LocationName = TempElement->LocationName;
8985 FoundElement = -1 - Position;
9001 unsigned int Count = 0;
9008 AnsiString SName, TName, ErrorString;
9010 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9016 throw Exception(
"Track element has FixedNamedLocationElement set but is not a footbridge/underpass in CheckLocationNameMultiMap, caller = " +
9017 AnsiString(Caller));
9030 (
"Inactive track element has FixedNamedLocationElement set but is not a platform, concourse or named location in CheckLocationNameMultiMap, caller = " +
9031 AnsiString(Caller));
9038 throw Exception(
"LocationNameMultiMap size = " + AnsiString(
LocationNameMultiMap.size()) +
" & Count = " + AnsiString(Count) +
9039 " in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9044 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9050 if(ErrorString !=
"")
9052 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for TrackVector check, caller = " + AnsiString(Caller));
9054 if(SNIt->second != -1 - (
int)x)
9056 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
9057 AnsiString(Caller));
9063 bool FoundFlag =
false;
9072 throw Exception(
"Track element with ActiveTrackElementName but no plat/named loc at H " + AnsiString(
TrackElementAt(1369, x).HLoc) +
" & V " +
9073 AnsiString(
TrackElementAt(1370, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9077 throw Exception(
"Track element with ActiveTrackElementName " + TName +
" but plat/named loc at H " + AnsiString(
TrackElementAt(1371, x).HLoc) +
9078 " & V " + AnsiString(
TrackElementAt(1372, x).VLoc) +
" has different LocationName in CheckLocationNameMultiMap, caller = " +
9079 AnsiString(Caller));
9084 throw Exception(
"Track element with ActiveTrackElementName but no inactive element at H " + AnsiString(
TrackElementAt(1373, x).HLoc) +
" & V " +
9085 AnsiString(
TrackElementAt(1374, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9095 if(ErrorString !=
"")
9097 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for InactiveTrackVector check, caller = " + AnsiString(Caller));
9099 if(SNIt->second != (
int)x)
9101 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
9102 AnsiString(Caller));
9112 AnsiString &ErrorString)
9120 AnsiString(TrackElement->HLoc) +
"," + AnsiString(TrackElement->VLoc) +
"," + AnsiString(TrackElement->SpeedTag));
9122 bool FoundFlag =
false;
9126 if(SNRange.first == SNRange.second)
9128 ErrorString =
"Error, Name " + LocationName +
" not found in map";
9130 return(SNRange.first);
9134 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9136 if(SNIterator->second < 0)
9138 int TVPos = -1 - SNIterator->second;
9140 if(TVIt == TrackElement)
9149 int ITVPos = SNIterator->second;
9151 if(ITVIt == TrackElement)
9162 ErrorString =
"Error, Name " + LocationName +
" found but not at required element";
9179 LocationNameEntry.first = NewName;
9180 LocationNameEntry.second = SNIterator->second;
9194 int TruePos = -1 - Position;
9198 throw Exception(
"Footbridge/underpass error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9208 throw Exception(
"Inactive element error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9231 InactiveTrack2MultiMapIterator++)
9233 if(InactiveTrack2MultiMapIterator->second > VecPos)
9235 InactiveTrack2MultiMapIterator->second--;
9243 LocationNameMultiMapIterator++)
9245 if(LocationNameMultiMapIterator->second < 0)
9249 if(LocationNameMultiMapIterator->second > (
int)VecPos)
9251 LocationNameMultiMapIterator->second--;
9273 for(TrackMapIterator =
TrackMap.begin(); TrackMapIterator !=
TrackMap.end(); TrackMapIterator++)
9275 if(TrackMapIterator->second > VecPos)
9277 TrackMapIterator->second--;
9285 LocationNameMultiMapIterator++)
9287 if(LocationNameMultiMapIterator->second >= 0)
9293 if(LocationNameMultiMapIterator->second < -(
int)(VecPos + 1))
9295 LocationNameMultiMapIterator->second++;
9299 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9305 if(TkEl.
Conn[0] ==
int(VecPos))
9310 if(TkEl.
Conn[0] >
int(VecPos))
9314 if(TkEl.
Conn[0] > -1)
9340 for(
unsigned int TVPos = 0; TVPos <
TrackVector.size(); TVPos++)
9346 LocationNameEntry.second = -1 - TVPos;
9357 LocationNameEntry.second = ITVPos;
9399 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9431 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9459 AnsiString((
short)FirstTrack));
9460 bool LengthDifferent =
false, SpeedDifferent =
false;
9467 int EXArray[16][2] =
9469 {2, 4}, {6, 2}, {8, 6}, {4, 8},
9470 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
9473 int Index = -1, BrNum = -1, GrNum = -1, InLink, OutLink;
9474 Graphics::TBitmap *Bitmap;
9478 InLink = TrackElement.
Link[0];
9479 OutLink = TrackElement.
Link[1];
9483 InLink = TrackElement.
Link[2];
9484 OutLink = TrackElement.
Link[3];
9486 for(
int x = 0; x < 16; x++)
9488 if((InLink == EXArray[x][0] && OutLink == EXArray[x][1]) || (InLink == EXArray[x][1] && OutLink == EXArray[x][0]))
9495 throw Exception(
"Error, failed to find Index in TTrack::MarkOneLength");
9514 else if(TrackElement.
SpeedTag == 54)
9518 else if(TrackElement.
SpeedTag == 55)
9529 else if(TrackElement.
SpeedTag == 58)
9533 else if(TrackElement.
SpeedTag == 59)
9538 else if(Index == 14)
9544 else if(TrackElement.
SpeedTag == 52)
9548 else if(TrackElement.
SpeedTag == 57)
9553 else if(Index == 15)
9559 else if(TrackElement.
SpeedTag == 53)
9563 else if(TrackElement.
SpeedTag == 56)
9577 if(LengthDifferent && SpeedDifferent)
9645 else if(LengthDifferent && !SpeedDifferent)
9792 AnsiString((
short)FirstTrack));
9793 LengthDifferent =
false;
9794 SpeedDifferent =
false;
9799 LengthDifferent =
true;
9803 SpeedDifferent =
true;
9805 if(LengthDifferent || SpeedDifferent)
9818 LengthDifferent =
true;
9822 SpeedDifferent =
true;
9824 if(LengthDifferent || SpeedDifferent)
9837 LengthDifferent =
true;
9841 SpeedDifferent =
true;
9843 if(LengthDifferent || SpeedDifferent)
9923 AnsiString TempName;
9924 int VecPos, StartVecPos, Count, EntryPos, StartEntryPos, ForwardNumber, ReverseNumber;
9925 bool ForwardSet, ReverseSet;
9927 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9932 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9970 for(
int y = 0; y < 2; y++)
10001 StartElement = TempElement;
10002 StartVecPos = VecPos;
10005 EntryPos = 1 - Dir;
10006 StartEntryPos = 1 - Dir;
10015 VecPos = TempElement.
Conn[1 - EntryPos];
10016 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
10018 EntryPos = TempEntryPos;
10046 ForwardNumber = ((Count + 1) / 2) + 1;
10047 ReverseNumber = (Count - ForwardNumber) + 1;
10049 EntryPos = 1 - Dir;
10050 TempElement = StartElement;
10051 VecPos = StartVecPos;
10052 if(Count == ForwardNumber)
10057 if(Count == ReverseNumber)
10065 VecPos = TempElement.
Conn[1 - EntryPos];
10066 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
10068 EntryPos = TempEntryPos;
10070 if(Count == ForwardNumber)
10075 if(Count == ReverseNumber)
10087 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10223 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10279 if((TextH / 16) - 1 <
HLocMin)
10283 if((TextH / 16) + 1 >
HLocMax)
10287 if((TextV / 16) - 1 <
VLocMin)
10291 if((TextV / 16) + 1 >
VLocMax)
10321 void TTrack::UserGraphicMove(
int Caller,
int HPosInput,
int VPosInput,
int &UserGraphicItem,
int &UserGraphicMoveHPos,
int &UserGraphicMoveVPos,
10322 bool &UserGraphicFoundFlag)
10325 TUserGraphicVector::iterator UserGraphicPtr;
10327 UserGraphicFoundFlag =
false;
10334 if((HPosInput >= (*UserGraphicPtr).HPos) && (HPosInput < ((*UserGraphicPtr).HPos + (*UserGraphicPtr).Width)) && (VPosInput >=
10335 (*UserGraphicPtr).VPos) && (VPosInput < ((*UserGraphicPtr).VPos + (*UserGraphicPtr).Height)))
10337 UserGraphicItem = x;
10338 UserGraphicMoveHPos = (*UserGraphicPtr).HPos;
10339 UserGraphicMoveVPos = (*UserGraphicPtr).VPos;
10340 UserGraphicFoundFlag =
true;
10358 int SpeedTag = TrackElement.
SpeedTag;
10362 throw Exception(
"Error - SpeedTag value " + AnsiString(SpeedTag) +
" in RetrieveStripedNamedLocationGraphicsWhereRelevant");
10411 return(GraphicOutput);
10419 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
10422 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in TrackElementAt");
10435 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
InactiveTrackVector.size()) +
", At: " + AnsiString(At) +
10436 " in InactiveTrackElementAt");
10447 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
10449 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in BlankElementAt");
10474 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
10475 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
10479 if(SNRange.first == SNRange.second)
10484 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
10486 if(SNIterator->second < 0)
10500 HVPair.first = InactiveElement.
HLoc;
10501 HVPair.second = InactiveElement.
VLoc;
10505 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in OneNamedLocationLongEnoughForSplit (1)");
10507 int TVPos =
TrackMap.find(HVPair)->second;
10510 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
10516 FirstNamedExitPos = 0;
10518 SecondNamedElement =
TrackElementAt(561, FirstNamedElement.
Conn[FirstNamedExitPos]);
10520 FirstNamedLinkedElement =
TrackElementAt(562, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10521 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10524 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10526 SecondNamedLinkedElement =
TrackElementAt(563, SecondNamedElement.
Conn[SecondNamedExitPos]);
10527 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10528 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10531 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10541 FirstNamedExitPos = 1;
10543 SecondNamedElement =
TrackElementAt(564, FirstNamedElement.
Conn[FirstNamedExitPos]);
10545 FirstNamedLinkedElement =
TrackElementAt(565, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10546 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10549 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10551 SecondNamedLinkedElement =
TrackElementAt(566, SecondNamedElement.
Conn[SecondNamedExitPos]);
10552 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10553 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10556 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10572 int &FirstNamedLinkedElementPos,
int &SecondNamedLinkedElementPos)
10586 AnsiString(FirstNamedElementPos));
10587 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
10588 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
10590 SecondNamedElementPos = -1;
10591 FirstNamedLinkedElementPos = -1;
10592 SecondNamedLinkedElementPos = -1;
10596 if(SNRange.first == SNRange.second)
10601 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
10603 if(SNIterator->second < 0)
10613 HVPair.first = InactiveElement.
HLoc;
10614 HVPair.second = InactiveElement.
VLoc;
10626 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in ThisNamedLocationLongEnoughForSplit (2)"
10630 int TVPos =
TrackMap.find(HVPair)->second;
10631 if(TVPos != FirstNamedElementPos)
10637 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
10643 FirstNamedExitPos = 0;
10645 SecondNamedElement =
TrackElementAt(568, FirstNamedElement.
Conn[FirstNamedExitPos]);
10647 FirstNamedLinkedElement =
TrackElementAt(569, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10648 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10651 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10653 SecondNamedLinkedElement =
TrackElementAt(570, SecondNamedElement.
Conn[SecondNamedExitPos]);
10654 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10655 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10658 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10660 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
10661 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
10662 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
10671 FirstNamedExitPos = 1;
10673 SecondNamedElement =
TrackElementAt(571, FirstNamedElement.
Conn[FirstNamedExitPos]);
10675 FirstNamedLinkedElement =
TrackElementAt(572, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10676 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10679 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10681 SecondNamedLinkedElement =
TrackElementAt(573, SecondNamedElement.
Conn[SecondNamedExitPos]);
10682 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10683 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10686 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10688 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
10689 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
10690 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
10711 if(SNRange.first != SNRange.second)
10713 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
10715 if(SNIterator->second < 0)
10737 "," + AnsiString(SpeedTag));
10748 throw Exception(
"Error, FoundFlag false in PlatformOnSignalSide after IsPlatformOrNamedNonStationLocationPresent called successfully");
10778 else if(SpeedTag == 69)
10804 else if(SpeedTag == 70)
10830 else if(SpeedTag == 71)
10867 AnsiString(NextEntryPos) +
"," + AnsiString(OwnTrainID));
10868 if(NextEntryPos < 0)
10881 if(NextEntryPos > 1)
10900 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in SelectVectorAt");
10912 AnsiString(VLocIn) +
"," + AnsiString(LinkIn));
10913 bool FoundFlag =
false;
10928 int VLocHi = -2000000000, VLocLo = 2000000000, HLoc = 2000000000;
10929 bool FoundFlag =
false;
10954 VPosHi = 16 * VLocHi;
10955 VPosLo = 16 * VLocLo;
10974 AnsiString(EndTVPosition));
10985 int Link0Squares = ((EndElement.
HLoc - NewHLocLink0) * (EndElement.
HLoc - NewHLocLink0)) +
10986 ((EndElement.
VLoc - NewVLocLink0) * (EndElement.
VLoc - NewVLocLink0));
10987 int Link1Squares = ((EndElement.
HLoc - NewHLocLink1) * (EndElement.
HLoc - NewHLocLink1)) +
10988 ((EndElement.
VLoc - NewVLocLink1) * (EndElement.
VLoc - NewVLocLink1));
10990 if(Link0Squares <= Link1Squares)
11008 AnsiString(LinkPos));
11027 if((LinkPos == 1) && (TE.
Attribute == 0))
11032 else if(LinkPos == 1)
11038 else if((LinkPos == 3) && (TE.
Attribute == 1))
11043 else if(LinkPos == 3)
11050 else if(LinkPos == 0)
11055 else if(LinkPos == 1)
11060 else if(LinkPos == 2)
11065 else if(LinkPos == 3)
11070 throw Exception(
"Error, failure in GetExitPos");
11119 if((TE.
Link[0] == Link) || (TE.
Link[1] == Link))
11123 else if((TE.
Link[2] == Link) || (TE.
Link[3] == Link))
11165 "," + AnsiString(DiagonalLinkNumber));
11170 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(8, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
TrainOnLink(9, HLoc - 1, VLoc, 9, TrainID)))
11175 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(10, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
TrainOnLink(11, HLoc, VLoc - 1, 9, TrainID)))
11180 if(((DiagonalLinkNumber == 3) &&
TrainOnLink(12, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(13, HLoc + 1, VLoc, 7, TrainID)))
11185 if(((DiagonalLinkNumber == 7) &&
TrainOnLink(14, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(15, HLoc, VLoc + 1, 3, TrainID)))
11201 AnsiString JustFileName =
"";
11206 int LastDelim = UGI.
FileName.LastDelimiter(
'\\');
11213 JustFileName = UGI.
FileName.SubString(LastDelim + 1, UGI.
FileName.Length() - LastDelim);
11232 typedef std::list<int> TNamePosList;
11233 TNamePosList NamePosList;
11234 typedef TNamePosList::iterator TNPLIt;
11236 typedef std::list<int> TOnePlatList;
11237 TOnePlatList OnePlatList;
11238 typedef TOnePlatList::iterator TOPLIt;
11241 NamePosList.clear();
11242 OnePlatList.clear();
11243 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
11245 if(
TrackElementAt(988, x).ActiveTrackElementName == LocationName)
11247 NamePosList.push_back(x);
11252 if(!NamePosList.empty())
11254 OnePlatList.push_back(NamePosList.back());
11255 NamePosList.pop_back();
11257 while(!OnePlatList.empty())
11259 TempInt = OnePlatList.front();
11262 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[0]);
11263 if(NPLIt != NamePosList.end() && ((TempElement.
Link[0] == 2) || (TempElement.
Link[0] == 4) || (TempElement.
Link[0] == 6) || (TempElement.
Link[0] == 8)))
11265 OnePlatList.push_back(TempElement.
Conn[0]);
11266 NamePosList.erase(NPLIt);
11268 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[1]);
11269 if(NPLIt != NamePosList.end() && ((TempElement.
Link[1] == 2) || (TempElement.
Link[1] == 4) || (TempElement.
Link[1] == 6) || (TempElement.
Link[1] == 8)))
11271 OnePlatList.push_back(TempElement.
Conn[1]);
11272 NamePosList.erase(NPLIt);
11275 OnePlatList.erase(OnePlatList.begin());
11276 if(OnePlatList.empty())
11279 if(!NamePosList.empty())
11281 OnePlatList.push_back(NamePosList.back());
11282 NamePosList.pop_back();
11299 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
UserGraphicVector.size()) +
", At: " + AnsiString(At) +
" in UserGraphicVectorAt");
11314 throw Exception(
"Return value negative in call to LastElementNumber");
11326 throw Exception(
"PrefDirVector empty in call to LastElementPtr");
11340 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedPrefDirElementAt");
11352 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
11353 " in GetModifiablePrefDirElementAt");
11363 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
11365 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedSearchElementAt");
11375 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
11377 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableSearchElementAt");
11394 int TrackVectorPosition;
11446 FinishElement =
false;
11447 int TrackVectorPosition;
11469 if(TrackElement.
HLoc >= StartPrefDirElement.
HLoc)
11479 if(TrackElement.
VLoc >= StartPrefDirElement.
VLoc)
11502 for(
int x = 0; x < 4; x++)
11525 FinishElement =
true;
11533 for(
int x = 0; x < 4; x++)
11545 FinishElement =
true;
11553 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
11560 .ELinkPos] ==
Lead))
11576 FinishElement =
true;
11595 FinishElement =
true;
11614 FinishElement =
true;
11629 FinishElement =
true;
11638 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
11654 FinishElement =
true;
11660 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
11683 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition));
11684 int VectorCount = 0;
11688 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
11690 for(
int x = 0; x < VectorCount; x++)
11697 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
11701 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
11702 SearchElement.
ELinkPos = NextELinkPos;
11723 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
11725 SearchElement.
XLinkPos = NextXLinkPos;
11751 for(
int x = 0; x < VectorCount; x++)
11763 for(
int x = 0; x < VectorCount; x++)
11777 for(
int x = 0; x < VectorCount; x++)
11791 for(
int x = 0; x < VectorCount; x++)
11801 for(
int x = 0; x < VectorCount; x++)
11812 SearchElement.
XLink = SearchElement.
Link[1];
11831 SearchElement.
XLink = SearchElement.
Link[3];
11844 for(
int x = 0; x < VectorCount; x++)
11859 XLinkPos = NextXLinkPos;
11860 CurrentTrackElement = SearchElement;
11879 throw Exception(
"Error, SearchVector empty");
11886 for(
int x = 0; x < 4; x++)
11939 throw Exception(
"Error in EntryExitNumber 1");
11958 if(PrefDirElement.
XLink == -1)
11970 if(PrefDirElement.
XLink != -1)
11974 throw Exception(
"Error in EntryExitNumber 2");
12012 LeadingPoints =
false;
12040 LeadingPoints =
true;
12056 AnsiString ErrorString;
12057 bool Error =
false;
12064 ErrorString =
"HLoc";
12070 ErrorString =
"VLoc";
12076 ErrorString =
"ELink";
12082 ErrorString =
"ELinkPos";
12088 ErrorString =
"XLink";
12094 ErrorString =
"XLinkPos";
12100 ErrorString =
"Tag";
12106 ErrorString =
"TrackVectorPosition";
12112 ErrorString =
"EXNumber";
12119 ErrorString =
"CheckCount";
12126 ErrorString =
"EntryGraphicPtr";
12132 ErrorString =
"EntryDirectionGraphicPtr";
12141 ErrorString =
"Last XLink not connected to this element";
12148 throw Exception(
"Error at " + AnsiString(Position) +
" " + ErrorString);
12172 for(
int PrefDirVecPos = (
PrefDirVector.size() - 1); PrefDirVecPos >= (int)x; PrefDirVecPos--)
12229 AnsiString((
short)BuildingPrefDir));
12232 if(PrefDirSize() == 0)
12237 for(
unsigned int x = 0; x < PrefDirSize(); x++)
12249 Disp->PlotOutput(12, (TempPrefDirElement.
HLoc * 16), (TempPrefDirElement.
VLoc * 16), TempPrefDirElement.
EXGraphicPtr);
12261 if(x == (PrefDirSize() - 1))
12270 if((PrefDirRoute ==
PrefDirCall) && BuildingPrefDir)
12272 HPos = GetFixedPrefDirElementAt(4, 0).
HLoc * 16;
12273 VPos = GetFixedPrefDirElementAt(5, 0).VLoc * 16;
12274 Disp->Rectangle(1, HPos, VPos,
clB0G0R5, 2, 2);
12276 if(PrefDirSize() > 1)
12278 unsigned int LatestPos = PrefDirSize() - 1;
12279 HPos = GetFixedPrefDirElementAt(6, LatestPos).HLoc * 16;
12280 VPos = GetFixedPrefDirElementAt(7, LatestPos).VLoc * 16;
12281 Disp->Rectangle(2, HPos, VPos,
clB5G0R0, 4, 2);
12302 int H, V, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12305 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
12309 H = MMIT->first.first;
12310 V = MMIT->first.second;
12313 if(PrefDirPos0 > -1)
12317 if(PrefDirPos1 > -1)
12321 if(PrefDirPos2 > -1)
12325 if(PrefDirPos3 > -1)
12329 if(PrefDirPos3 > -1)
12345 else if(PrefDirPos2 > -1)
12387 else if(PrefDirPos1 > -1)
12410 else if(PrefDirPos0 > -1)
12429 int NumberOfPrefDirElements = 0;
12432 for(
int x = 0; x < NumberOfPrefDirElements; x++)
12434 VecFile >> TempInt;
12437 VecFile >> TempInt;
12438 LoadPrefDirElement.
ELink = TempInt;
12439 VecFile >> TempInt;
12440 LoadPrefDirElement.
ELinkPos = TempInt;
12441 VecFile >> TempInt;
12442 LoadPrefDirElement.
XLink = TempInt;
12443 VecFile >> TempInt;
12444 LoadPrefDirElement.
XLinkPos = TempInt;
12445 VecFile >> TempInt;
12446 LoadPrefDirElement.
EXNumber = TempInt;
12447 VecFile >> TempInt;
12452 if(!(LoadPrefDirElement.
IsARoute))
12478 int NumberOfPrefDirElements = 0;
12481 for(
int x = 0; x < NumberOfPrefDirElements; x++)
12483 VecFile >> TempInt;
12484 VecFile >> TempInt;
12487 VecFile >> TempInt;
12488 LoadPrefDirElement.
ELink = TempInt;
12489 VecFile >> TempInt;
12490 LoadPrefDirElement.
ELinkPos = TempInt;
12491 VecFile >> TempInt;
12492 LoadPrefDirElement.
XLink = TempInt;
12493 VecFile >> TempInt;
12494 LoadPrefDirElement.
XLinkPos = TempInt;
12495 VecFile >> TempInt;
12496 LoadPrefDirElement.
EXNumber = TempInt;
12497 VecFile >> TempInt;
12502 if(!(LoadPrefDirElement.
IsARoute))
12530 int NumberOfPrefDirElements = 0;
12533 if((NumberOfPrefDirElements < 0) || (NumberOfPrefDirElements > 1000000))
12538 for(
int x = 0; x < NumberOfPrefDirElements; x++)
12545 VecFile >> TempInt;
12546 if((TempInt < 0) || (TempInt >= NumberOfActiveElements))
12551 VecFile >> TempInt;
12552 if((TempInt < -1) || (TempInt > 9))
12557 VecFile >> TempInt;
12558 if((TempInt < -1) || (TempInt > 3))
12563 VecFile >> TempInt;
12564 if((TempInt < -1) || (TempInt > 9))
12569 VecFile >> TempInt;
12570 if((TempInt < -1) || (TempInt > 3))
12575 VecFile >> TempInt;
12576 if((TempInt < -1) || (TempInt > 27))
12581 VecFile >> TempInt;
12589 VecFile >> TempInt;
12590 if((TempInt != 0) && (TempInt != 1))
12595 VecFile >> TempInt;
12596 if((TempInt != 0) && (TempInt != 1))
12601 VecFile >> TempInt;
12602 if((TempInt != 0) && (TempInt != 1))
12625 for(
int y = 0; y < NumberOfPrefDirElements; y++)
12627 VecFile << y <<
'\n';
12628 VecFile <<
PrefDirVector.at(y).TrackVectorPosition <<
'\n';
12638 if(y == (NumberOfPrefDirElements - 1))
12640 VecFile <<
"************" <<
'\0' <<
'\n';
12644 VecFile <<
"******" <<
'\0' <<
'\n';
12658 for(
int y = 0; y < NumberOfSearchElements; y++)
12660 VecFile << y <<
'\n';
12661 VecFile <<
SearchVector.at(y).TrackVectorPosition <<
'\n';
12671 if(y == (NumberOfSearchElements - 1))
12673 VecFile <<
"************" <<
'\0' <<
'\n';
12677 VecFile <<
"******" <<
'\0' <<
'\n';
12790 bool AlreadyPresent, FoundFlag;
12791 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12793 for(
unsigned int x = 0; x < InputPrefDir->
PrefDirSize(); x++)
12797 AlreadyPresent =
false;
12802 AlreadyPresent =
true;
12806 AlreadyPresent =
true;
12810 AlreadyPresent =
true;
12814 AlreadyPresent =
true;
12817 if(!AlreadyPresent)
12864 for(
unsigned int z = 0; z < 4; z++)
12872 throw Exception(
"Error in RebuildPrefDirVector - PrefDirVector is unsafe");
12886 bool DiscrepancyFound =
false;
12897 DiscrepancyFound =
true;
12902 DiscrepancyFound =
true;
12907 DiscrepancyFound =
true;
12912 DiscrepancyFound =
true;
12917 DiscrepancyFound =
true;
12923 DiscrepancyFound =
true;
12926 if(DiscrepancyFound)
12928 ShowMessage(
"Discrepancies found in the preferred direction file, preferred directions will be cleared");
12943 bool DiscrepancyFound =
false;
12954 DiscrepancyFound =
true;
12958 DiscrepancyFound =
true;
12963 DiscrepancyFound =
true;
12968 DiscrepancyFound =
true;
12973 DiscrepancyFound =
true;
12979 DiscrepancyFound =
true;
12983 return(!DiscrepancyFound);
12995 bool FoundFlag =
false;
12996 int PrefDir0, PrefDir1, PrefDir2, PrefDir3;
13004 throw Exception(
"CheckPrefDir4MultiMap Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
13005 " in PrefDir4MultiMap, Caller=" + (AnsiString)Caller);
13007 if((PrefDir0 != (
int)a) && (PrefDir1 != (
int)a) && (PrefDir2 != (
int)a) && (PrefDir3 != (
int)a))
13009 throw Exception(
"CheckPrefDir4MultiMap Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
13010 (AnsiString)CheckElement.
VLoc +
" Map values=" + (AnsiString)PrefDir0 +
", " + (AnsiString)PrefDir1 +
", " + (AnsiString)PrefDir2 +
", " +
13011 (AnsiString)PrefDir3 +
" PrefDirVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
13016 throw Exception(
"CheckPrefDir4MultiMap Error - Map Size=" + (AnsiString)
PrefDirVector.size() +
" PrefDirVectorSize=" + (AnsiString)
PrefDirVector.size()
13017 +
" Caller=" + (AnsiString)Caller);
13043 PrefDirMapKeyPair.first = HLoc;
13044 PrefDirMapKeyPair.second = VLoc;
13045 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13048 if(ItPair.first == ItPair.second)
13056 PrefDirPos0 = ItPair.first->second;
13058 if(ItPair.first == ItPair.second)
13063 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13065 PrefDirPos1 = ItPair.first->second;
13068 if(ItPair.first == ItPair.second)
13073 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13075 PrefDirPos2 = ItPair.first->second;
13078 if(ItPair.first == ItPair.second)
13083 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13085 PrefDirPos3 = ItPair.first->second;
13100 +
"," + AnsiString(LinkNumberPos));
13102 int PD0, PD1, PD2, PD3;
13103 if(
PrefDirVector.at(PrefDirVectorNumber).Conn[LinkNumberPos] > -1)
13107 PD0, PD1, PD2, PD3);
13119 LinkedPrefDirVectorNumber = PD0;
13128 LinkedPrefDirVectorNumber = PD1;
13138 LinkedPrefDirVectorNumber = PD0;
13147 LinkedPrefDirVectorNumber = PD1;
13156 LinkedPrefDirVectorNumber = PD2;
13165 LinkedPrefDirVectorNumber = PD3;
13170 LinkedPrefDirVectorNumber = -1;
13176 LinkedPrefDirVectorNumber = -1;
13181 catch(
const Exception &e)
13183 LinkedPrefDirVectorNumber = -1;
13195 int PD0, PD1, PD2, PD3;
13247 THVPair PrefDir4MultiMapKeyPair;
13250 PrefDir4MultiMapKeyPair.first = LoadPrefDirElement.
HLoc;
13251 PrefDir4MultiMapKeyPair.second = LoadPrefDirElement.
VLoc;
13252 PrefDir4MultiMapEntry.first = PrefDir4MultiMapKeyPair;
13275 throw Exception(
"Failed to find PrefDir4MultiMap erase element");
13294 AnsiString(ErasedElementNumber));
13299 if(MapPtr->second > ErasedElementNumber)
13321 throw Exception(
"PrefDirVectorPosition out of range");
13324 THVPair PrefDir4MultiMapKeyPair;
13326 PrefDir4MultiMapKeyPair.first = PrefDirElement.
HLoc;
13327 PrefDir4MultiMapKeyPair.second = PrefDirElement.
VLoc;
13328 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13331 if(ItPair.first == ItPair.second)
13334 return(ItPair.first);
13338 if(ItPair.first->second == PrefDirVectorPosition)
13342 return(ItPair.first);
13345 if(ItPair.first == ItPair.second)
13348 return(ItPair.first);
13350 if(ItPair.first->second == PrefDirVectorPosition)
13354 return(ItPair.first);
13357 if(ItPair.first == ItPair.second)
13360 return(ItPair.first);
13362 if(ItPair.first->second == PrefDirVectorPosition)
13366 return(ItPair.first);
13369 if(ItPair.first == ItPair.second)
13372 return(ItPair.first);
13374 if(ItPair.first->second == PrefDirVectorPosition)
13378 return(ItPair.first);
13382 return(ItPair.first);
13395 THVPair PrefDir4MultiMapKeyPair;
13397 PrefDir4MultiMapKeyPair.first = HLoc;
13398 PrefDir4MultiMapKeyPair.second = VLoc;
13399 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13402 if(ItPair.first == ItPair.second)
13410 return(ItPair.first->second);
13419 bool ErasedFlag =
false;
13421 if(ErasedTrackVectorPosition > -1)
13430 ErasedFlag =
false;
13432 if(
PrefDirVector.at(x).TrackVectorPosition == ErasedTrackVectorPosition)
13437 else if(
PrefDirVector.at(x).Conn[0] == ErasedTrackVectorPosition)
13442 else if(
PrefDirVector.at(x).Conn[1] == ErasedTrackVectorPosition)
13447 else if(
PrefDirVector.at(x).Conn[2] == ErasedTrackVectorPosition)
13452 else if(
PrefDirVector.at(x).Conn[3] == ErasedTrackVectorPosition)
13460 if(
PrefDirVector.at(x).TrackVectorPosition > ErasedTrackVectorPosition)
13464 if(
PrefDirVector.at(x).Conn[0] > ErasedTrackVectorPosition)
13468 if(
PrefDirVector.at(x).Conn[1] > ErasedTrackVectorPosition)
13472 if(
PrefDirVector.at(x).Conn[2] > ErasedTrackVectorPosition)
13476 if(
PrefDirVector.at(x).Conn[3] > ErasedTrackVectorPosition)
13491 OverallDistance = 0;
13492 OverallSpeedLimit = 0;
13493 LeadingPointsAtLastElement =
false;
13501 LeadingPointsAtLastElement =
true;
13510 OverallDistance += PrefDirElement.
Length23;
13511 if(OverallSpeedLimit != -1)
13521 OverallSpeedLimit = -1;
13528 OverallDistance += PrefDirElement.
Length01;
13529 if(OverallSpeedLimit != -1)
13539 OverallSpeedLimit = -1;
13558 int H, V, HLoc, VLoc, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
13561 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
13565 HLoc = MMIT->first.first;
13566 VLoc = MMIT->first.second;
13571 if(PrefDirPos0 > -1)
13575 if(PrefDirPos1 > -1)
13579 if(PrefDirPos2 > -1)
13583 if(PrefDirPos3 > -1)
13587 if(PrefDirPos3 > -1)
13590 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
13592 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
13594 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
13596 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement3.
GetRouteGraphicPtr(
false,
true));
13603 else if(PrefDirPos2 > -1)
13608 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
13610 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
13612 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
false));
13621 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
13623 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
13625 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
13634 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
13636 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
13638 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
13645 else if(PrefDirPos1 > -1)
13650 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
13652 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
13660 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
13662 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
13668 else if(PrefDirPos0 > -1)
13670 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
13687 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
13690 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
13711 if(PrefDirPos0 > -1)
13715 if(PrefDirPos1 > -1)
13719 if(PrefDirPos2 > -1)
13723 if(PrefDirPos3 > -1)
13727 if(PrefDirPos3 > -1)
13732 else if(PrefDirPos2 > -1)
13734 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos) || (PrefDirElement2.
XLinkPos == EntryPos))
13745 else if(PrefDirPos1 > -1)
13747 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos))
13758 else if(PrefDirPos0 > -1)
13760 if(PrefDirElement0.
XLinkPos == EntryPos)
13797 ElementIn.
VLoc +
"," + XLink);
13799 bool TrackFoundFlag;
13802 if((XLink == 2) || (XLink == 4) || (XLink == 6) || (XLink == 8))
13814 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
13824 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
13838 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
13848 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
13862 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
13872 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
13886 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
13896 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
13919 bool FoundFlag, ContFlag, FoundElements =
false;
13920 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
13925 LastIteratorValue++;
13950 if(PDVIt->XLinkPos == 0)
13955 StartElement = *PDVIt;
13964 int NextTrackVectorPosition = PDVIt->
Conn[PDVIt->GetXLinkPos()];
13966 Track->
TrackElementAt(879, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
13967 if(PrefDirPos0 == -1)
13971 bool NextElementFoundFlag =
false;
13975 NextElementFoundFlag =
true;
13977 if(PrefDirPos1 > -1)
13982 NextElementFoundFlag =
true;
13985 if(PrefDirPos2 > -1)
13990 NextElementFoundFlag =
true;
13993 if(PrefDirPos3 > -1)
13998 NextElementFoundFlag =
true;
14001 if(!NextElementFoundFlag)
14031 EndElement = NextElement;
14035 NextTrackVectorPosition = NextElement.
Conn[NextElement.
GetXLinkPos()];
14037 Track->
TrackElementAt(881, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
14038 if(PrefDirPos0 == -1)
14048 if(PrefDirPos1 > -1)
14056 if(PrefDirPos2 > -1)
14064 if(PrefDirPos3 > -1)
14095 FoundElements =
true;
14129 AnsiString(VLoc) +
"," + AnsiString((
short)AutoSigsFlag));
14131 int TrackVectorPosition;
14167 int LockedVectorNumber;
14190 bool InPrefDirFlag =
false;
14193 int PrefDirPos0 = -1;
14194 int PrefDirPos1 = -1;
14195 int PrefDirPos2 = -1;
14196 int PrefDirPos3 = -1;
14200 int PrefDirVecPos[4] =
14202 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
14205 for(
int x = 0; x < 4; x++)
14207 int b = PrefDirVecPos[x];
14217 InPrefDirFlag =
true;
14231 "Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
14239 if(DummyPair.first > -1)
14241 throw Exception(
"Selection in two routes - should never happen!");
14243 if(RoutePair.first > -1)
14319 IDInt &ReqPosRouteID,
bool &PointsChanged)
14353 AnsiString(VLoc) +
"," + AnsiString((
short)ConsecSignals) +
"," + AnsiString((
short)AutoSigsFlag));
14403 bool InPrefDirFlag =
false;
14406 int PrefDirPos0 = -1;
14407 int PrefDirPos1 = -1;
14408 int PrefDirPos2 = -1;
14409 int PrefDirPos3 = -1;
14412 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
14413 int PrefDirVecPos[4] =
14415 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
14418 for(
int x = 0; x < 4; x++)
14420 int b = PrefDirVecPos[x];
14423 InPrefDirFlag =
true;
14437 "Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
14446 if(RoutePair.first > -1)
14448 if(RoutePair.second != 0)
14465 EndElement1 = RouteElement;
14466 EndElement2 = BlankElement;
14566 PointsChanged =
true;
14594 PointsChanged =
true;
14617 PointsChanged =
true;
14646 PointsChanged =
true;
14660 PointsChanged =
true;
14679 PointsChanged =
true;
14693 PointsChanged =
true;
14709 PointsChanged =
true;
14763 TOnePrefDir *EveryPrefDir,
bool ConsecSignals,
int EndPosition,
bool AutoSigsFlag)
14816 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString(
ReqPosRouteID.
GetInt()) +
"," + AnsiString(EndPosition) +
"," +
14817 AnsiString((
short)AutoSigsFlag));
14818 int VectorCount = 0;
14822 if((PrefDirElement.
XLink == 1) || (PrefDirElement.
XLink == 3) || (PrefDirElement.
XLink == 7) || (PrefDirElement.
XLink == 9))
14826 for(
int x = 0; x < VectorCount; x++)
14834 bool FirstPass =
true;
14844 for(
int x = 0; x < VectorCount; x++)
14853 for(
int x = 0; x < VectorCount; x++)
14865 for(
int x = 0; x < VectorCount; x++)
14873 int NextPosition = PrefDirElement.
Conn[XLinkPos];
14877 int NextELinkPos = PrefDirElement.
ConnLinkPos[XLinkPos];
14878 SearchElement.
ELinkPos = NextELinkPos;
14879 SearchElement.
ELink = SearchElement.
Link[NextELinkPos];
14900 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
14902 SearchElement.
XLinkPos = NextXLinkPos;
14914 for(
int x = 0; x < VectorCount; x++)
14928 if(RoutePair.first > -1)
14937 for(
int x = 0; x < VectorCount; x++)
14946 if(SecondPair.first > -1)
14955 for(
int x = 0; x < VectorCount; x++)
14969 for(
int x = 0; x < VectorCount; x++)
14980 for(
int x = 0; x < VectorCount; x++)
14989 for(
int x = 0; x < VectorCount; x++)
14998 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15002 for(
int x = 0; x < VectorCount; x++)
15012 bool InPrefDirFlag =
false;
15013 PrefDirElement1 = BlankElement;
15014 PrefDirElement2 = BlankElement;
15017 int PrefDirPos0 = -1;
15018 int PrefDirPos1 = -1;
15019 int PrefDirPos2 = -1;
15020 int PrefDirPos3 = -1;
15023 int PrefDirVecPos[4] =
15025 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
15027 for(
int x = 0; x < 4; x++)
15029 int b = PrefDirVecPos[x];
15032 InPrefDirFlag =
true;
15045 for(
int x = 0; x < VectorCount; x++)
15057 for(
int x = 0; x < VectorCount; x++)
15073 for(
int x = 0; x < VectorCount; x++)
15093 for(
int x = 0; x < VectorCount; x++)
15110 for(
int x = 0; x < VectorCount; x++)
15120 for(
int x = 0; x < VectorCount; x++)
15131 int SearchPos1 = SearchElement.
Attribute + 1;
15133 if(SearchPos1 == 2)
15137 if(SearchPos1 == 1)
15145 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
15146 SearchElement.
XLinkPos = SearchPos1;
15147 InPrefDirFlag =
false;
15148 if(SearchElement.
XLink == PrefDirElement1.
XLink)
15150 SearchElement = PrefDirElement1;
15151 InPrefDirFlag =
true;
15153 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
15155 SearchElement = PrefDirElement2;
15156 InPrefDirFlag =
true;
15162 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15166 for(
int x = 0; x < VectorCount; x++)
15193 for(
int x = 0; x < VectorCount; x++)
15211 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
15212 SearchElement.
XLinkPos = SearchPos2;
15213 if(SearchElement.
XLink == PrefDirElement1.
XLink)
15215 SearchElement = PrefDirElement1;
15217 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
15219 SearchElement = PrefDirElement2;
15223 for(
int x = 0; x < VectorCount; x++)
15231 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15235 for(
int x = 0; x < VectorCount; x++)
15263 for(
int x = 0; x < VectorCount; x++)
15275 for(
int x = 0; x < VectorCount; x++)
15285 SearchElement = PrefDirElement1;
15294 XLinkPos = SearchElement.
XLinkPos;
15295 PrefDirElement = SearchElement;
15352 unsigned int TruncatePrefDirPosition = 0;
15425 throw Exception(
"Error - failed to validate extended route for preferred route");
15480 throw Exception(
"Error - failed to validate single route for preferred route");
15525 AnsiString(VLoc) +
"," + AnsiString((
short)Callon));
15527 int TrackVectorPosition;
15564 int LockedVectorNumber;
15598 PrefDirElement1.
ELink = PrefDirElement1.
Link[0];
15599 PrefDirElement1.
XLink = PrefDirElement1.
Link[1];
15602 throw Exception(
"Error, No EXNumber for PrefDirElement1 in GetNonPreferredRouteStartElement");
15608 PrefDirElement2.
ELink = PrefDirElement2.
Link[1];
15609 PrefDirElement2.
XLink = PrefDirElement2.
Link[0];
15612 throw Exception(
"Error, No EXNumber for PrefDirElement2 in GetNonPreferredRouteStartElement");
15626 if(RoutePair.first > -1)
15824 EndElement1.
ELink = EndElement1.
Link[0];
15825 EndElement1.
XLink = EndElement1.
Link[1];
15828 throw Exception(
"Error, No EXNumber for EndElement1 in GetNonPreferredRouteStartElement");
15833 EndElement2.
ELink = EndElement2.
Link[1];
15834 EndElement2.
XLink = EndElement2.
Link[0];
15837 throw Exception(
"Error, No EXNumber for EndElement2 in GetNonPreferredRouteStartElement");
15881 if(RoutePair.first > -1)
15883 if(RoutePair.second != 0)
15906 EndElement2 = BlankElement;
15991 PointsChanged =
true;
16017 PointsChanged =
true;
16039 PointsChanged =
true;
16065 PointsChanged =
true;
16079 PointsChanged =
true;
16119 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString() +
"," + AnsiString(
ReqPosRouteID.
GetInt()));
16120 int VectorCount = 0;
16123 if((CurrentTrackElement.
Link[XLinkPos] == 1) || (CurrentTrackElement.
Link[XLinkPos] == 3) || (CurrentTrackElement.
Link[XLinkPos] == 7) ||
16124 (CurrentTrackElement.
Link[XLinkPos] == 9))
16128 for(
int x = 0; x < VectorCount; x++)
16140 for(
int x = 0; x < VectorCount; x++)
16147 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
16149 for(
int x = 0; x < VectorCount; x++)
16156 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
16160 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
16161 SearchElement.
ELinkPos = NextELinkPos;
16182 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
16184 SearchElement.
XLinkPos = NextXLinkPos;
16197 for(
int x = 0; x < VectorCount; x++)
16211 if(RoutePair.first > -1)
16220 for(
int x = 0; x < VectorCount; x++)
16229 if(SecondPair.first > -1)
16238 for(
int x = 0; x < VectorCount; x++)
16252 for(
int x = 0; x < VectorCount; x++)
16263 for(
int x = 0; x < VectorCount; x++)
16272 for(
int x = 0; x < VectorCount; x++)
16281 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16285 for(
int x = 0; x < VectorCount; x++)
16298 for(
int x = 0; x < VectorCount; x++)
16330 for(
int x = 0; x < VectorCount; x++)
16340 for(
int x = 0; x < VectorCount; x++)
16351 int SearchPos1 = SearchElement.
Attribute + 1;
16353 if(SearchPos1 == 2)
16357 if(SearchPos1 == 1)
16366 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
16367 SearchElement.
XLinkPos = SearchPos1;
16369 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16373 for(
int x = 0; x < VectorCount; x++)
16398 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
16399 SearchElement.
XLinkPos = SearchPos2;
16401 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16405 for(
int x = 0; x < VectorCount; x++)
16424 for(
int x = 0; x < VectorCount; x++)
16439 CurrentTrackElement = SearchElement;
16440 XLinkPos = SearchElement.
XLinkPos;
16462 throw Exception(
"Error, SearchVector empty");
16474 for(
int x = 0; x < 4; x++)
16516 throw Exception(
"Error in EntryExitNumber 3");
16571 unsigned int TruncatePrefDirPosition = 0;
16631 throw Exception(
"Failed to validate extended route for nonpreferred route");
16676 throw Exception(
"Failed to validate single route for nonpreferred route");
16696 if(!PrefDirVector.empty())
16700 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 1) || (PrefDirPtr->XLinkPos == 1)))
16705 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 3) || (PrefDirPtr->XLinkPos == 3)))
16740 if(!PrefDirVector.empty())
16743 TPrefDirElement LastElement = GetFixedPrefDirElementAt(185, PrefDirSize() - 1);
16745 int ForwardLinkedRouteNumber, Attribute = 0;
16752 if(ForwardLinkedRouteNumber > -1)
16754 int NextForwardLinkedRouteNumber = -1;
16758 ForwardLinkedRouteNumber = NextForwardLinkedRouteNumber;
16768 GetFixedPrefDirElementAt(193, 0).XLinkPos, RouteNumber);
16788 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 1) || (SearchPtr->XLinkPos == 1)))
16796 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 3) || (SearchPtr->XLinkPos == 3)))
16827 NextForwardLinkedRouteNumber = -1;
16828 for(
unsigned int x = 0; x < PrefDirSize(); x++)
16830 int TrainID =
Track->
TrackElementAt(100, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnElement;
16831 if(PrefDirVector.at(x).TrackType ==
Bridge)
16833 if(PrefDirVector.at(x).XLinkPos < 2)
16835 TrainID =
Track->
TrackElementAt(101, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeTrackPos01;
16839 TrainID =
Track->
TrackElementAt(102, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeTrackPos23;
16847 if(PrefDirVector.at(x).TrackType ==
Buffers)
16859 if(
Track->
IsLCAtHV(42, PrefDirVector.at(x).HLoc, PrefDirVector.at(x).VLoc))
16868 if(PrefDirVector.at(x).Config[PrefDirVector.at(x).XLinkPos] ==
Signal)
16870 Attribute =
Track->
TrackElementAt(103, PrefDirVector.at(x).TrackVectorPosition).Attribute + 1;
16878 if(x == PrefDirSize() - 1)
16922 AnsiString(PrefDirVectorStartPosition));
16927 bool SkipContinuationAndBufferAttributeChange =
false;
16929 if(!PrefDirVector.empty())
16931 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr < PrefDirVector.end(); PrefDirPtr++)
16934 if(PrefDirPtr->TrackType ==
Bridge)
16936 if(PrefDirPtr->XLinkPos < 2)
16947 SkipContinuationAndBufferAttributeChange =
true;
16962 SkipContinuationAndBufferAttributeChange =
true;
16970 SkipContinuationAndBufferAttributeChange =
true;
16972 if(!SkipContinuationAndBufferAttributeChange)
16974 if(PrefDirVector.back().TrackType ==
Buffers)
16983 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr >= PrefDirVector.begin(); PrefDirPtr--)
16986 if(PrefDirPtr->TrackType ==
Bridge)
16988 if(PrefDirPtr->XLinkPos < 2)
17004 if(
Track->
IsLCAtHV(20, PrefDirPtr->HLoc, PrefDirPtr->VLoc))
17013 if(PrefDirPtr->Config[PrefDirPtr->XLinkPos] ==
Signal)
17015 if((!
AllRoutes->
RouteTruncateFlag) || (PrefDirPtr != (PrefDirVector.begin() + PrefDirVectorStartPosition)) || PrefDirPtr->AutoSignals ||
17016 PrefDirPtr->PrefDirRoute)
17020 int LockedVecNum = 0;
17022 bool KeepAttributeAt0ForLockedRoute =
false;
17027 KeepAttributeAt0ForLockedRoute =
true;
17047 if((Attribute < 3) && !KeepAttributeAt0ForLockedRoute)
17075 "," + AnsiString((
short)PrefDirRoute));
17076 bool ElementInRoute =
false;
17077 bool TrainOccupyingRoute =
false;
17083 ElementInRoute =
true;
17087 if(!ElementInRoute)
17115 TrainOccupyingRoute =
true;
17182 if(LRVIT->RouteNumber == RouteNumber)
17196 int button = Application->MessageBox(L
"Train approaching or occupying route, YES to lock route (2 minutes to release), NO to cancel",
17197 L
"Warning!", MB_YESNO | MB_ICONWARNING);
17209 bool ExistingLockedRouteModified =
false;
17222 if(LRVIT->RouteNumber == RouteNumber)
17226 ExistingLockedRouteModified =
true;
17230 if(!ExistingLockedRouteModified)
17320 AnsiString((
short)PrefDirRoute));
17345 AnsiString((
short)PrefDirRoute));
17355 RouteFlashElement.
HLoc = H;
17356 RouteFlashElement.
VLoc = V;
17372 int H = PrefDirPtr->HLoc;
17373 int V = PrefDirPtr->VLoc;
17440 for(
unsigned int x = 0; x < RouteFlashVector.size(); x++)
17446 Display->
PlotOutput(21, RouteFlashVector.at(x).HLoc * 16, RouteFlashVector.at(x).VLoc * 16, RouteFlashVector.at(x).OriginalGraphic);
17449 OverlayPlotted =
false;
17459 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
17461 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedRouteAt");
17464 return(AllRoutesVector.at(At));
17473 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
17475 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableRouteAt");
17478 return(AllRoutesVector.at(At));
17489 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
17491 GetFixedRouteAt(62, a).PrefDirMarker(7,
RouteCall,
false, Disp);
17501 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
17503 GetFixedRouteAt(166, a).RouteImageMarker(0, Bitmap);
17521 AnsiString(VLoc) +
"," + AnsiString((
short)PrefDirRoute));
17522 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
17525 RouteTruncateFlag =
true;
17527 GetModifiableRouteAt(7, a).GetRouteTruncateElement(0, HLoc, VLoc, PrefDirRoute, ReturnFlag);
17528 RouteTruncateFlag =
false;
17557 AnsiString(LinkPos));
17558 if(TrackVectorPosition == -1)
17563 THVPair Route2MultiMapKeyPair;
17567 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
17570 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
17580 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
17582 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
17585 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(64, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(88,
17586 Route2MultiMapIterator->second.second);
17587 EntryLinkPos = PrefDirElement1.
ELinkPos;
17588 ExitLinkPos = PrefDirElement1.
XLinkPos;
17589 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
17590 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
17602 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
17614 Graphics::TBitmap* &EntryDirectionGraphicPtr)
17624 AnsiString(LinkPos));
17627 if(TrackVectorPosition == -1)
17632 THVPair Route2MultiMapKeyPair;
17636 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
17639 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
17644 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
17646 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
17648 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(73, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(97,
17649 Route2MultiMapIterator->second.second);
17650 EntryLinkPos = PrefDirElement1.
ELinkPos;
17651 ExitLinkPos = PrefDirElement1.
XLinkPos;
17652 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
17653 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
17657 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(74,
17658 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
17665 return(AutoSigsRoute);
17670 return(NotAutoSigsRoute);
17676 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(75,
17677 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
17684 return(AutoSigsRoute);
17689 return(NotAutoSigsRoute);
17693 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
17695 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
17696 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
17698 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(76, ItPair.first->second.first).GetFixedPrefDirElementAt(98, ItPair.first->second.second);
17699 EntryLinkPos = PrefDirElement2.
ELinkPos;
17700 ExitLinkPos = PrefDirElement2.
XLinkPos;
17701 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
17702 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
17706 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(77, ItPair.first->second.first).PrefDirSize() - 1))
17713 return(AutoSigsRoute);
17718 return(NotAutoSigsRoute);
17724 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(78, ItPair.first->second.first).PrefDirSize() - 1))
17731 return(AutoSigsRoute);
17736 return(NotAutoSigsRoute);
17740 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(79, ItPair.second->second.first).GetFixedPrefDirElementAt(99, ItPair.second->second.second);
17741 EntryLinkPos = PrefDirElement3.
ELinkPos;
17742 ExitLinkPos = PrefDirElement3.
XLinkPos;
17743 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
17744 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
17748 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(80, ItPair.second->second.first).PrefDirSize() - 1))
17755 return(AutoSigsRoute);
17760 return(NotAutoSigsRoute);
17766 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(81, ItPair.second->second.first).PrefDirSize() - 1))
17773 return(AutoSigsRoute);
17778 return(NotAutoSigsRoute);
17794 AnsiString(LinkPos));
17795 if(TrackVectorPosition == -1)
17801 THVPair Route2MultiMapKeyPair;
17805 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
17808 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
17814 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
17816 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
17818 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(82, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(100,
17819 Route2MultiMapIterator->second.second);
17820 EntryLinkPos = PrefDirElement1.
ELinkPos;
17821 ExitLinkPos = PrefDirElement1.
XLinkPos;
17822 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
17823 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
17826 RouteNumber = Route2MultiMapIterator->second.first;
17830 return(AutoSigsRoute);
17835 return(NotAutoSigsRoute);
17840 RouteNumber = Route2MultiMapIterator->second.first;
17844 return(AutoSigsRoute);
17849 return(NotAutoSigsRoute);
17853 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
17855 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
17856 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
17858 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(83, ItPair.first->second.first).GetFixedPrefDirElementAt(101, ItPair.first->second.second);
17859 EntryLinkPos = PrefDirElement2.
ELinkPos;
17860 ExitLinkPos = PrefDirElement2.
XLinkPos;
17861 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
17862 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
17865 RouteNumber = ItPair.first->second.first;
17869 return(AutoSigsRoute);
17874 return(NotAutoSigsRoute);
17879 RouteNumber = ItPair.first->second.first;
17883 return(AutoSigsRoute);
17888 return(NotAutoSigsRoute);
17892 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(84, ItPair.second->second.first).GetFixedPrefDirElementAt(102, ItPair.second->second.second);
17893 EntryLinkPos = PrefDirElement3.
ELinkPos;
17894 ExitLinkPos = PrefDirElement3.
XLinkPos;
17895 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
17896 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
17899 RouteNumber = ItPair.second->second.first;
17903 return(AutoSigsRoute);
17908 return(NotAutoSigsRoute);
17913 RouteNumber = ItPair.second->second.first;
17917 return(AutoSigsRoute);
17922 return(NotAutoSigsRoute);
17944 EmptyRoute.
RouteID = NextRouteID;
17947 AllRoutesVector.push_back(EmptyRoute);
17948 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
17973 AllRoutesVector.push_back(EmptyRoute);
17974 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
17997 THVPair Route2MultiMapKeyPair;
18006 LockedRouteTruncateTrackVectorPosition = 0;
18007 LockedRouteLastTrackVectorPosition = 0;
18008 LockedRouteLastXLinkPos = 0;
18009 LockedRouteLockStartTime = TDateTime(0);
18010 if(!LockedRouteVector.empty())
18014 if(LRVIT->RouteNumber == RouteNumber)
18016 LockedRouteTruncateTrackVectorPosition = LRVIT->TruncateTrackVectorPosition;
18017 LockedRouteLastTrackVectorPosition = LRVIT->LastTrackVectorPosition;
18018 LockedRouteLastXLinkPos = LRVIT->LastXLinkPos;
18019 LockedRouteLockStartTime = LRVIT->LockStartTime;
18020 LockedRouteFoundDuringRouteBuilding =
true;
18021 LockedRouteVector.erase(LRVIT);
18046 AnsiString(VLoc) +
"," + AnsiString(ELink));
18049 ReturnPair.first = -1;
18050 ReturnPair.second = 0;
18051 THVPair Route2MultiMapKeyPair;
18053 Route2MultiMapKeyPair.first = HLoc;
18054 Route2MultiMapKeyPair.second = VLoc;
18057 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
18058 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
18060 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
18061 Route2MultiMapIterator = ItPair.first;
18063 if(ItPair.first == ItPair.second)
18065 throw Exception(
"Failed to find Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc);
18067 if(GetFixedRouteAt(111, ItPair.first->second.first).GetFixedPrefDirElementAt(132, ItPair.first->second.second).GetELink() == ELink)
18069 ReturnPair.first = ItPair.first->second.first;
18070 ReturnPair.second = ItPair.first->second.second;
18071 Route2MultiMapIterator = ItPair.first;
18073 return(ReturnPair);
18076 if(ItPair.first == ItPair.second)
18078 throw Exception(
"Found Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc +
" but failed to find required element");
18080 if(GetFixedRouteAt(112, ItPair.first->second.first).GetFixedPrefDirElementAt(133, ItPair.first->second.second).GetELink() == ELink)
18082 ReturnPair.first = ItPair.first->second.first;
18083 ReturnPair.second = ItPair.first->second.second;
18084 Route2MultiMapIterator = ItPair.first;
18086 return(ReturnPair);
18089 return(ReturnPair);
18104 AnsiString(VLoc) +
"," + AnsiString(ELink));
18105 THVPair Route2MultiMapKeyPair;
18107 Route2MultiMapKeyPair.first = HLoc;
18108 Route2MultiMapKeyPair.second = VLoc;
18109 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
18111 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
18113 if(ItPair.first == ItPair.second)
18119 if(GetFixedRouteAt(205, ItPair.first->second.first).GetFixedPrefDirElementAt(241, ItPair.first->second.second).GetELink() == ELink)
18121 RouteNumber = ItPair.first->second.first;
18127 if(ItPair.first == ItPair.second)
18133 if(GetFixedRouteAt(206, ItPair.first->second.first).GetFixedPrefDirElementAt(242, ItPair.first->second.second).GetELink() == ELink)
18135 RouteNumber = ItPair.first->second.first;
18156 "," + AnsiString(ELinkIn) +
"," + AnsiString(RouteNumber) +
"," + AnsiString(RouteElementNumber));
18157 THVPair Route2MultiMapKeyPair;
18159 Route2MultiMapKeyPair.first = HLoc;
18160 Route2MultiMapKeyPair.second = VLoc;
18163 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
18166 RouteElementPair.first = RouteNumber;
18167 RouteElementPair.second = RouteElementNumber;
18168 Route2MultiMapEntry.second = RouteElementPair;
18170 if(Route2MultiMap.find(Route2MultiMapKeyPair) != Route2MultiMap.end())
18173 if(GetFixedRouteAt(113, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(134,
18174 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).GetELink() != ELinkIn)
18177 if(GetFixedRouteAt(114, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(135,
18178 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).TrackType !=
Bridge)
18180 throw Exception(
"Error, bridge expected in Route2MultiMapInsert but not, at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
18182 Route2MultiMap.insert(Route2MultiMapEntry);
18187 throw Exception(
"Error, route map entry found in Route2MultiMapInsert at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
18192 Route2MultiMap.insert(Route2MultiMapEntry);
18210 TempPair.first = -1;
18211 TempPair.second = 0;
18212 SecondPair = TempPair;
18214 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItRange;
18215 THVPair Route2MultiMapKeyPair;
18217 Route2MultiMapKeyPair.first = HLoc;
18218 Route2MultiMapKeyPair.second = VLoc;
18219 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
18224 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
18226 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
18228 return(Route2MultiMapIterator->second);
18230 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
18232 ItRange = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
18233 TempPair = ItRange.first->second;
18234 SecondPair = (--ItRange.second)->second;
18257 TRouteElementPair RouteElementPair = GetRouteElementDataFromRoute2MultiMap(8, CheckElement.
HLoc, CheckElement.
VLoc, SecondPair);
18258 if(RouteElementPair.first == -1)
18261 throw Exception(
"CheckMapAndRoutes Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
18262 " in Route2MultiMap, Caller=" + (AnsiString)Caller);
18264 if((RouteElementPair.first != (
int)a) && (SecondPair.first != (
int)a))
18267 throw Exception(
"CheckMapAndRoutes Error - RouteNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
18268 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)RouteElementPair.first +
" Route value=" + (AnsiString)a +
" Caller=" +
18269 (AnsiString)Caller);
18271 if(((RouteElementPair.first != (
int)a) || (RouteElementPair.second != b)) && ((SecondPair.first != (
int)a) || (SecondPair.second != b)))
18274 throw Exception(
"CheckMapAndRoutes Error - PrefDirVectorNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
18275 (AnsiString)CheckElement.
VLoc +
" 1st Map value RouteNum/ElementNum =" + (AnsiString)RouteElementPair.first +
"/" +
18276 (AnsiString)RouteElementPair.second +
" 2nd Map value =" + (AnsiString)SecondPair.first +
"/" + (AnsiString)SecondPair.second +
18277 " Route value=" + (AnsiString)a +
"/" + (AnsiString)b +
" Caller=" + (AnsiString)Caller);
18281 unsigned int SizeVal = 0;
18284 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
18286 SizeVal += GetFixedRouteAt(117, a).PrefDirSize();
18288 if(SizeVal != Route2MultiMap.size())
18290 throw Exception(
"CheckMapAndRoutes Error - Map Size=" + (AnsiString)Route2MultiMap.size() +
" RouteSize=" + (AnsiString)SizeVal +
" Caller=" +
18291 (AnsiString)Caller);
18307 if(!Route2MultiMap.empty())
18309 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
18311 if(Route2MultiMapIterator->second.first > RouteNumber)
18313 Route2MultiMapIterator->second.first--;
18330 AnsiString(RouteNumber) +
"," + AnsiString(ErasedElementNumber));
18331 if(!Route2MultiMap.empty())
18333 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
18335 if((Route2MultiMapIterator->second.first == RouteNumber) && (Route2MultiMapIterator->second.second > ErasedElementNumber))
18337 Route2MultiMapIterator->second.second--;
18356 AnsiString(ELink));
18360 RequiredRoutePair = FindRoutePairFromRoute2MultiMap(0, HLoc, VLoc, ELink, Route2MultiMapIterator);
18361 if(RequiredRoutePair.first == -1)
18363 throw Exception(
"Failed to find route element in RemoveRouteElement");
18365 Route2MultiMap.erase(Route2MultiMapIterator);
18366 DecrementRouteElementNumbersInRoute2MultiMap(0, RequiredRoutePair.first, RequiredRoutePair.second);
18369 TPrefDirElement LockedRouteElement, PrefDirElement = GetFixedRouteAt(118, RequiredRoutePair.first).GetFixedPrefDirElementAt(137, RequiredRoutePair.second);
18390 GetModifiableRouteAt(8, RequiredRoutePair.first).EraseRouteElementAt(&(GetModifiableRouteAt(9, RequiredRoutePair.first).GetModifiablePrefDirElementAt(1,
18391 RequiredRoutePair.second)));
18402 if(AutoSigVectorIT->RouteNumber == RequiredRoutePair.first)
18410 if(GetModifiableRouteAt(10, RequiredRoutePair.first).PrefDirSize() == 0)
18412 TrainController->
LogEvent(
"RouteRemoved," + AnsiString(GetFixedRouteAt(189, RequiredRoutePair.first).RouteID));
18413 AllRoutesVector.erase(AllRoutesVector.begin() + RequiredRoutePair.first);
18414 DecrementRouteNumbersInRoute2MultiMap(0, RequiredRoutePair.first);
18426 if(!LockedRouteVector.empty())
18430 if(LRVIT->RouteNumber > RequiredRoutePair.first)
18432 LRVIT->RouteNumber--;
18442 if(AutoSigVectorIT->RouteNumber > RequiredRoutePair.first)
18444 AutoSigVectorIT->RouteNumber--;
18449 CheckMapAndRoutes(7);
18463 AnsiString(ELink) +
"," + AnsiString(RouteNumber) +
"," + RouteElement.
LogPrefDir());
18464 GetModifiableRouteAt(11, RouteNumber).StoreRouteElementInPrefDirVector(RouteElement);
18465 Route2MultiMapInsert(0, HLoc, VLoc, ELink, RouteNumber, GetModifiableRouteAt(12, RouteNumber).
PrefDirSize() - 1);
18481 "," + AnsiString(XLinkPos));
18485 RouteElementPair = GetRouteElementDataFromRoute2MultiMap(9, TE.
HLoc, TE.
VLoc, SecondPair);
18486 if(RouteElementPair.first == -1)
18488 throw Exception(
"Error, failed to find element in SetTrailingSignalsOnAutoSigsRoute - 1");
18490 TPrefDirElement RouteElement = GetFixedRouteAt(119, RouteElementPair.first).GetFixedPrefDirElementAt(138, RouteElementPair.second);
18492 RequiredPair = RouteElementPair;
18493 if(RouteElement.
XLinkPos != XLinkPos)
18495 if(SecondPair.first != -1)
18497 RouteElement = GetFixedRouteAt(120, SecondPair.first).GetFixedPrefDirElementAt(139, SecondPair.second);
18498 RequiredPair = SecondPair;
18499 if(RouteElement.
XLinkPos != XLinkPos)
18501 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 2");
18506 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 3");
18510 SetAllRearwardsSignals(5, 0, RequiredPair.first, RequiredPair.second);
18530 AnsiString(AccessNumber));
18532 int Attribute = AccessNumber + 1;
18534 int x = GetFixedRouteAt(121, RouteNumber).PrefDirSize() - 1;
18538 throw Exception(
"Error - route not AutoSignals in SetTrailingSignalsOnContinuationRoute");
18542 throw Exception(
"Error - end element not continuation in SetTrailingSignalsOnContinuationRoute");
18545 x).XLinkPos] !=
End)
18547 throw Exception(
"Error - end element a continuation in SetTrailingSignalsOnContinuationRoute but End not facing right way");
18550 SetAllRearwardsSignals(6, Attribute, RouteNumber, GetFixedRouteAt(126, RouteNumber).
PrefDirSize() - 1);
18593 AnsiString(RouteNumber) +
"," + AnsiString(RouteStartPosition));
18594 TPrefDirElement FirstElement = GetFixedRouteAt(127, RouteNumber).GetFixedPrefDirElementAt(144, 0);
18595 int RearwardLinkedRouteNumber;
18621 int TrainID, TrainPosition, BehindTrainPosition;
18622 bool FoundTrain =
false, BehindTrain =
false;
18623 for(
int x = RouteStartPosition; x >= 0; x--)
18625 TPrefDirElement PrefDirElement = GetFixedRouteAt(132, RouteNumber).GetFixedPrefDirElementAt(146, x);
18650 if(FoundTrain && (TrainPosition > 1))
18652 for(
int x = TrainPosition; x >= 0; x--)
18657 TPrefDirElement PrefDirElement = GetFixedRouteAt(133, RouteNumber).GetFixedPrefDirElementAt(147, x);
18677 BehindTrain =
true;
18678 BehindTrainPosition = x;
18685 SetAllRearwardsSignals(7, 0, RouteNumber, BehindTrainPosition);
18702 AnsiString(RouteTruncatePosition));
18703 int SignalCount = 0, TrainID, RearwardLinkedRouteNumber, StartPosition = RouteTruncatePosition;
18704 TOneRoute CurrentRoute = GetFixedRouteAt(134, RouteNumber);
18707 bool ExamineRoute =
true;
18709 while(ExamineRoute)
18711 for(
int x = StartPosition; x >= 0; x--)
18753 if(SignalCount >= 3)
18772 CurrentRoute = GetFixedRouteAt(135, RearwardLinkedRouteNumber);
18773 ExamineRoute =
true;
18774 StartPosition = GetFixedRouteAt(136, RearwardLinkedRouteNumber).PrefDirSize() - 1;
18809 ExamineRoute =
false;
18824 AnsiString(TrackVectorPosition) +
"," + AnsiString(XLinkPos));
18827 PrefDirElement = InternalPrefDirElement;
18828 if(LockedRouteVector.empty())
18835 bool InLockedRoute =
false;
18839 if(TrackIsInARoute(14, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos))
18843 InLockedRoute =
true;
18852 int RouteNumber, VectorCount = 0;
18857 RouteType = GetRouteTypeAndNumber(8, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos, RouteNumber);
18858 if(RouteType == NoRoute)
18864 GetFixedRouteAt(140, RouteNumber).
PrefDirSize() - 1).XLinkPos != LRVIT->LastXLinkPos))
18867 (
"Error, last element in locked route doesn't correspond with last element in associated route in IsElementInLockedRouteGetPrefDirElement");
18869 for(
int x = GetFixedRouteAt(141, RouteNumber).
PrefDirSize() - 1; x >= 0; x--)
18871 InternalPrefDirElement = GetFixedRouteAt(142, RouteNumber).GetFixedPrefDirElementAt(152, x);
18872 if(InternalPrefDirElement.
TrackVectorPosition != (
int)LRVIT->TruncateTrackVectorPosition)
18876 PrefDirElement = InternalPrefDirElement;
18877 LockedVectorNumber = VectorCount;
18882 else if(InternalPrefDirElement.
TrackVectorPosition == (
int)LRVIT->TruncateTrackVectorPosition)
18886 PrefDirElement = InternalPrefDirElement;
18887 LockedVectorNumber = VectorCount;
18908 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
18910 if(GetFixedRouteAt(157, x).RouteID ==
RouteID.GetInt())
18916 throw Exception(
"Error, failed to find RouteID in GetRouteVectorNumber for ID: " + AnsiString(
RouteID.GetInt()));
18926 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
18928 if(GetFixedRouteAt(45, x).RouteID ==
RouteID.GetInt())
18943 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
18945 if(GetFixedRouteAt(163, x).RouteID ==
RouteID.GetInt())
18948 return(GetFixedRouteAt(159, x));
18951 throw Exception(
"Error, failed to find RouteID in GetFixedRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
18959 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
18961 if(GetFixedRouteAt(164, x).RouteID ==
RouteID.GetInt())
18964 return(GetModifiableRouteAt(15, x));
18967 throw Exception(
"Error, failed to find RouteID in GetModifiableRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
18977 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
18979 TOneRoute OneRoute = GetFixedRouteAt(165, x);
18991 int NumberOfRoutes;
18995 for(
int x = 0; x < NumberOfRoutes; x++)
19002 StoreOneRouteAfterSessionLoad(0, &OneRoute);
19020 if((NumberOfRoutes < 0) || (NumberOfRoutes > 5000))
19027 if((NextID < 0) || (NextID > 1000000))
19032 for(
int x = 0; x < NumberOfRoutes; x++)
19057 AnsiString(StartPosition));
19058 if(EndPosition == StartPosition)
19064 int TVPos = EndPosition;
19065 int LkPos = EndXLinkPos;
19067 while(TrackIsInARoute(15, TVPos, LkPos))
19094 if(GetRouteTypeAndNumber(36, NewTVPos, NewLkPos, RouteNumber) == NoRoute)
19103 if((NewLkPos == 0) || (NewLkPos == 2))
19123 if(TVPos == StartPosition)
19155 AnsiString(VLoc) +
"," + AnsiString(DiagonalLinkNumber));
19160 if(FirstPair.first > -1)
19163 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
19168 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19174 if(SecondPair.first > -1)
19177 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
19182 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19188 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(0, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(1, HLoc - 1, VLoc,
19195 if(FirstPair.first > -1)
19198 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19203 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19209 if(SecondPair.first > -1)
19212 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19217 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19223 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(2, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(3, HLoc, VLoc - 1,
19230 if(FirstPair.first > -1)
19233 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19238 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19244 if(SecondPair.first > -1)
19247 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19252 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19258 if(((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(4, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(5, HLoc + 1, VLoc,
19265 if(FirstPair.first > -1)
19268 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19273 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
19279 if(SecondPair.first > -1)
19282 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19287 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
19293 if(((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(6, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(7, HLoc, VLoc + 1,
19317 "," + AnsiString(DiagonalLinkNumber));
19322 if(FirstPair.first > -1)
19325 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
19330 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19336 if(SecondPair.first > -1)
19339 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
19344 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19351 if(FirstPair.first > -1)
19354 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19359 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19365 if(SecondPair.first > -1)
19368 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19373 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19380 if(FirstPair.first > -1)
19383 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19388 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19394 if(SecondPair.first > -1)
19397 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19402 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19409 if(FirstPair.first > -1)
19412 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19417 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
19423 if(SecondPair.first > -1)
19426 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19431 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))